-
Notifications
You must be signed in to change notification settings - Fork 371
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add async/await support to test cases. Add test case for setInitialOw…
…ner.
- Loading branch information
1 parent
33c62f5
commit f5f398f
Showing
4 changed files
with
69 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"ignore": ["*.min.js"], | ||
"compact": false, | ||
"presets": ["es2015", "stage-2", "stage-3"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"dependencies": { | ||
"babel-preset-es2015": "^6.3.13", | ||
"babel-preset-stage-2": "^6.3.13", | ||
"babel-preset-stage-3": "^6.3.13", | ||
"babel-polyfill": "^6.7.4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
require('babel-polyfill'); | ||
var CryptoPunks2 = artifacts.require("./CryptoPunks2.sol"); | ||
|
||
contract('CryptoPunks2', function (accounts) { | ||
it("Should start with 0 balance", async function () { | ||
var contract = await CryptoPunks2.deployed(); | ||
|
||
await contract.setInitialOwner(accounts[0],0); | ||
var balance = await contract.balanceOf.call(accounts[0]); | ||
assert.equal(balance.valueOf(), 1, "Didn't get the initial punk"); | ||
var owner = await contract.punkIndexToAddress.call(0); | ||
assert.equal(owner, accounts[0], "Ownership array wrong"); | ||
var remaining = await contract.punksRemainingToAssign.call(); | ||
assert.equal(9999, remaining); | ||
}), | ||
it("Can not claim punk after set initial owners assigned", async function () { | ||
var contract = await CryptoPunks2.deployed(); | ||
await contract.allInitialOwnersAssigned(); | ||
try { | ||
await contract.setInitialOwner(accounts[0],0); | ||
assert(false, "Should have thrown exception."); | ||
} catch (err) { | ||
// Should catch an exception | ||
} | ||
|
||
}), | ||
it("can not pass an invalid index to assign initial", async function () { | ||
var contract = await CryptoPunks2.deployed(); | ||
try { | ||
await contract.setInitialOwner(accounts[0],10000); | ||
assert(false, "Should have thrown exception."); | ||
} catch (err) { | ||
// Should catch an exception | ||
} | ||
|
||
}), | ||
it("only owner can assign initial", async function () { | ||
var contract = await CryptoPunks2.deployed(); | ||
try { | ||
await contract.setInitialOwner(accounts[1],1); | ||
assert(false, "Should have thrown exception."); | ||
} catch (err) { | ||
// Should catch an exception | ||
} | ||
|
||
}) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#21