Solidity 정리 3!
유튜브 영상 자료(Dapp Campus)를 따라해보면서 배우고 있는 중입니다. 한번 따라해보면 처음에 익숙해지는데 꽤나 좋을 것 같습니다.
여기서는 로또비스무리한 컨트랙트를 만들고 있군요. 그래서 Lottery Contract로 만들어 보고 있습니다.
오늘은 테스트입니다.
Truffle에는 javascript test library인 Mocha 를 스마트컨트랙트 형태로 약간 변형하여 사용할 수 있도록 제공 됩니다.
lottery.test.js 소스
// parameter에는 truffle 실행시 최초 제공된 account list(총 10개)에서 0번주소, 1번주소, 2번주소 이렇게 값을 받아옴
const Lottery = artifacts.require("Lottery");
contract("Lottery", function ([deployer, user1, user2]) {
let lottery;
// 테스트 전에 미리 실행 하는 함수
beforeEach(async () => {
console.log("Basic Test");
lottery = await Lottery.new(); // 스마트 컨트랙트 배포
});
// 테스트 Module
it("Basic test", async () => {
console.log("Basic Test");
let owner = await lottery.owner();
let value = await lottery.getSomeValue();
console.log(`owner:${owner}, value:${value}`);
assert.equal(owner, "0x105Dd1dB1EE66aeC9D7259a45544081Dd93F04FF");
assert.equal(value, 36);
});
});
test 실행
// truffle console에서 실행
truffle test ./test/lottery.test.js
[US$140.00](▼54%)샤오미 드리미 V10 무선 청소기 / 유럽버전! / 6개월무료A/S / 무료배송/
WWW.QOO10.COMDownvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
하~ 이상한걸 하고 계시군요!! ㅋㅋㅋㅋㅋ
즐거운 하루 되세요^^
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
이상한거라뇨!! ㅋㅋ 열공중입니다! ㅎㅎ
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
@happyberrysboy transfered 15 KRWP to @krwp.burn. voting percent : 66.86%, voting power : 59.87%, steem power : 2013409.53, STU KRW : 1200.
@happyberrysboy staking status : 7650 KRWP
@happyberrysboy limit for KRWP voting service : 7.65 KRWP (rate : 0.001)
What you sent : 15 KRWP
Refund balance : 7.35 KRWP [50270288 - 3ba53f8e842e038e0905efc568d566c05d7ee0da]
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit