[Solidity] 230720 study
9. ERC721 Token Transfers - Single step, Two step (~11)
-
const result = await contractInstance.createRandomZombie(zombieNames[0], {from: alice});- 처음에 그대로 입력했는데 안돼서, 페이지 로딩하고 그대로 복붙해보니까 됐다. 뭐지..?
12. Zombie Attacks
13. More Expressive Assertions with Chai
assert vs. Chai
- bulit-in 함수인 assert를 썼는데, 코드 가독성을 위해 Chai를 써보도록 하자
npm -g install chai로 설치
- Chai는
expect,should,assert를 각각 지원하고, 그 내용은 다음과 같다expect-
let lessonTitle = "Testing Smart Contracts with Truffle"; expect(lessonTitle).to.be.a.("string");
-
should-
let lessonTitle = "Testing Smart contracts with Truffle"; lessonTitle.should.be.a.("string");
-
assert-
let lessonTitle = "Testing Smart contracts with Truffle"; assert.typeOf(lessonTitle, "string");
-
- 기본적으로 다음 구문을 통해서
expect를 이용할 수 있다var expect = require('chai').expect
assert구문을 모두expect(변수명).to.equal(expected)로 바꿨다.