Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct Post {
- uint256 amt;
- bool isActive;
- address owner;
- }
- Post[] public posts;
- function createP(uint256 amt) public payable returns(uint a) {
- posts.push(Post({
- amt: amt,
- isActive: false,
- owner: msg.sender
- }));
- return (posts.length);
- }
- function getPostLength() returns(uint a){
- return (posts.length);
- }
- MyContract.deployed()
- .then(async instance => {
- const weiSpend = web3.toWei(2, "ether");
- var id = await instance.createP.call(10,{
- from: accounts[0],
- value: weiSpend
- });
- var id2 = await instance.createP.call(50,{
- from: accounts[1],
- value: weiSpend
- });
- var id3 = await instance.createP.call(100,{
- from: accounts[2],
- value: weiSpend
- });
- var last = await instance.getPostLength.call();
- console.log(id3.toString()); // returns 1 instead of 3
- console.log(last.toString()); // returns 0 instead of 3
- });
Add Comment
Please, Sign In to add comment