add tests for libs

This commit is contained in:
Iuri Matias 2017-12-27 08:37:39 -05:00
parent cff999def8
commit 33adaf360b
3 changed files with 47 additions and 0 deletions

View 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;
}
}

View 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;
}
}

View 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();
});
});
});