-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
js tests added, slight contract changes
- Loading branch information
Nick Zoghb
committed
Sep 29, 2017
1 parent
368bf1b
commit d16ab1d
Showing
5 changed files
with
85 additions
and
32 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 |
---|---|---|
@@ -1,18 +1,18 @@ | ||
var Greeter = artifacts.require("./Greeter.sol"); | ||
|
||
contract('Greeter', function(accounts) { | ||
/* In general, it is not good practice to hard-code test values */ | ||
const args = {_greeting: "Hello, World!"}; | ||
it("Should use the Greeter constructor to set a greeting", function() { | ||
/* Constructor arguement already sent in `migrations/2_deploy_greeter.js` */ | ||
return Greeter.deployed() | ||
.then(function(instance) { | ||
/* Call the greet function */ | ||
return instance.greet.call(); | ||
}) | ||
.then(function(result) { | ||
assert.equal(args._greeting, result, `Greeter constructor greeting | ||
and test value do not match`) | ||
}) | ||
}); | ||
/* In general, it is not good practice to hard-code test values */ | ||
const args = {_greeting: "Hello, World!"}; | ||
it("Should use the Greeter constructor to set a greeting", function() { | ||
/* Constructor arguement already sent in `migrations/2_deploy_greeter.js` */ | ||
return Greeter.deployed() | ||
.then(function(instance) { | ||
/* Call the greet function */ | ||
return instance.greet.call(); | ||
}) | ||
.then(function(result) { | ||
assert.equal(args._greeting, result, "Greeter constructor " + | ||
"greeting and test value do not match") | ||
}); | ||
}); | ||
}); |
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
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
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
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,62 @@ | ||
var Betting = artifacts.require("./Betting.sol"); | ||
|
||
contract('BettingTestGeneric', function(accounts) { | ||
const args = {_default: accounts[0], _owner: accounts[1]}; | ||
|
||
it("The contract can be deployed", function() { | ||
return Betting.new() | ||
.then(function(instance) { | ||
assert.ok(instance.address); | ||
}); | ||
}); | ||
|
||
it("The contract can be deployed by custom addresses (default)", function() { | ||
return Betting.new() | ||
.then(function(instance) { | ||
return instance.owner.call(); | ||
}) | ||
.then(function(result) { | ||
assert.equal(result, args._default, "contract owned by " + | ||
"the wrong address"); | ||
}); | ||
}); | ||
|
||
it("The contract can be deployed by custom addresses (using 'from')", function() { | ||
return Betting.new({from: args._owner}) | ||
.then(function(instance) { | ||
return instance.owner.call(); | ||
}) | ||
.then(function(result) { | ||
assert.equal(result, args._owner, "contract owned by " + | ||
"the wrong address"); | ||
}); | ||
}); | ||
}); | ||
|
||
contract('BettingTestOracleSet', function(accounts) { | ||
const null_address = '0x0000000000000000000000000000000000000000'; | ||
const args = {_owner: accounts[1], _oracle: accounts[2], | ||
_other: accounts[3], _fail: null_address}; | ||
|
||
it("The Owner can set a new Oracle", function() { | ||
return Betting.new({from: args._owner}) | ||
.then(function(instance) { | ||
return instance.chooseOracle.call(args._oracle, {from: args._owner}); | ||
}) | ||
.then(function(result) { | ||
assert.equal(result, args._oracle, "Oracle address and test " + | ||
"values do not match"); | ||
}); | ||
}); | ||
|
||
it("The Oracle cannot be set by non-Owner addresses", function() { | ||
return Betting.new({from: args._owner}) | ||
.then(function(instance) { | ||
return instance.chooseOracle.call(args._oracle, {from: args._other}); | ||
}) | ||
.then(function(result) { | ||
assert.equal(result, args._fail, "Oracle address and test " + | ||
"values should both be uninitialized addresses"); | ||
}); | ||
}); | ||
}); |