mirror of
https://github.com/status-im/embark-area-51.git
synced 2025-02-02 18:34:09 +00:00
add tests for libs
This commit is contained in:
parent
cff999def8
commit
33adaf360b
16
test_app/app/contracts/test2.sol
Normal file
16
test_app/app/contracts/test2.sol
Normal file
@ -0,0 +1,16 @@
|
||||
pragma solidity ^0.4.17;
|
||||
|
||||
import "./zlib2.sol";
|
||||
|
||||
contract Test2 {
|
||||
address public addr;
|
||||
|
||||
function testAdd() public pure returns (uint _result) {
|
||||
return ZAMyLib2.add(1, 2);
|
||||
}
|
||||
|
||||
function changeAddress(address _addr) public {
|
||||
addr = _addr;
|
||||
}
|
||||
|
||||
}
|
9
test_app/app/contracts/zlib2.sol
Normal file
9
test_app/app/contracts/zlib2.sol
Normal file
@ -0,0 +1,9 @@
|
||||
pragma solidity ^0.4.17;
|
||||
|
||||
library ZAMyLib2 {
|
||||
|
||||
function add(uint _a, uint _b) public pure returns (uint _c) {
|
||||
return _a + _b;
|
||||
}
|
||||
|
||||
}
|
22
test_app/test/lib_test_spec.js
Normal file
22
test_app/test/lib_test_spec.js
Normal file
@ -0,0 +1,22 @@
|
||||
describe("Test", function() {
|
||||
before(function(done) {
|
||||
this.timeout(0);
|
||||
var contractsConfig = {
|
||||
"Test": {
|
||||
"gas": 2000000
|
||||
},
|
||||
"ZAMyLib2": {
|
||||
"deploy": true
|
||||
}
|
||||
};
|
||||
EmbarkSpec.deployAll(contractsConfig, () => { done() });
|
||||
});
|
||||
|
||||
it("should call library correctly", function(done) {
|
||||
Test2.testAdd(function(err, result) {
|
||||
assert.equal(result.toNumber(), 3);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user