|
| 1 | +require('babel-polyfill'); |
1 | 2 | var CryptoPunks2 = artifacts.require("./CryptoPunks2.sol"); |
2 | 3 |
|
3 | 4 | contract('CryptoPunks2', function (accounts) { |
@@ -193,48 +194,13 @@ contract('CryptoPunks2', function (accounts) { |
193 | 194 | // return contract.buyPunk(1001, {from: accounts[2], value: 10000}); |
194 | 195 | }) |
195 | 196 | }), |
196 | | - it("only owner can call setInitialOwner", function () { |
197 | | - var contract; |
198 | | - return CryptoPunks2.deployed().then(function (instance) { |
199 | | - contract = instance; |
200 | | - return instance.setInitialOwner(accounts[1], 10000); |
201 | | - }).then(function () { |
202 | | - // console.log("Bought punk."); |
203 | | - assert(false, "Was supposed to throw but didn't."); |
204 | | - }).catch(function (error) { |
205 | | - if (error.toString().indexOf("invalid opcode") != -1) { |
206 | | - // Expecting a throw here |
207 | | - // console.log("We were expecting a Solidity throw (aka an invalid JUMP), we got one. Test succeeded."); |
208 | | - } else { |
209 | | - // if the error is something else (e.g., the assert from previous promise), then we fail the test |
210 | | - assert(false, error.toString()); |
211 | | - } |
212 | | - // Get account 0 to buy a punk with enough ether |
213 | | - // console.log("Buying punk 1001 with account 2 which should be allowed."); |
214 | | - // return contract.buyPunk(1001, {from: accounts[2], value: 10000}); |
215 | | - }) |
216 | | - }), |
217 | | - it("should not be able to call setInitialOwner after contract set to all initial assigned", function () { |
218 | | - var contract; |
219 | | - return CryptoPunks2.deployed().then(function (instance) { |
220 | | - contract = instance; |
221 | | - return contract.allInitialOwnersAssigned(); |
222 | | - }).then(function () { |
223 | | - return contract.setInitialOwner(accounts[0], 0); |
224 | | - }).then(function () { |
225 | | - // console.log("Bought punk."); |
226 | | - assert(false, "Was supposed to throw but didn't."); |
227 | | - }).catch(function (error) { |
228 | | - if (error.toString().indexOf("invalid opcode") != -1) { |
229 | | - // Expecting a throw here |
230 | | - // console.log("We were expecting a Solidity throw (aka an invalid JUMP), we got one. Test succeeded."); |
231 | | - } else { |
232 | | - // if the error is something else (e.g., the assert from previous promise), then we fail the test |
233 | | - assert(false, error.toString()); |
234 | | - } |
235 | | - // Get account 0 to buy a punk with enough ether |
236 | | - // console.log("Buying punk 1001 with account 2 which should be allowed."); |
237 | | - // return contract.buyPunk(1001, {from: accounts[2], value: 10000}); |
238 | | - }) |
| 197 | + it("only owner can call setInitialOwner", async function () { |
| 198 | + var contract = await CryptoPunks2.deployed(); |
| 199 | + try { |
| 200 | + await instance.setInitialOwner(accounts[1], 10000); |
| 201 | + assert(false, "Should have thrown exception."); |
| 202 | + } catch (err) { |
| 203 | + // Should catch an exception |
| 204 | + } |
239 | 205 | }); |
240 | 206 | }); |
0 commit comments