You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.
I'm testing my contracts using Truffle, but my functions are not returning the correct uint, despite doing so when testing in Remix. This is my Test.js code:
var EventContract = artifacts.require("./EventContract.sol");
contract ('EventContract', function (accounts){
it("account1 purchases 4 tickets from ticketContract, which had 10 tickets to start with at a cost of 2", function(){
var event;
var account1 = accounts[0];
return EventContract.deployed()
.then(function(instance){
event = instance;
return event.buyTicketsFromContract.call(account1, 2, {from: account1, value: 4});
})
.then (function (success){
console.log("purchased from contract with success: " + success);
assert.equal(true, success, "bought 2 tickets for 4 ether");
return event.getContractTicketBalance.call();
})
.then (function(contractBalance){
console.log(contractBalance.toNumber());
// Fails here
assert.equal(8, contractBalance.toNumber(), "contract ticket balance is not 8");
return event.getTicketBalance.call(account1);
})
.then (function(accountBalance){
assert.equal(2, accountBalance.toNumber(), "account balance is not 2");
})
;
})
;
It fails because the contract ticket balance is 10 (initial amount), not 8. When using the same functions on Remix, the values returned are correct.
I'm testing my contracts using Truffle, but my functions are not returning the correct uint, despite doing so when testing in Remix. This is my Test.js code:
It fails because the contract ticket balance is 10 (initial amount), not 8. When using the same functions on Remix, the values returned are correct.
Someone else on Github also had this issue a couple days ago: https://ethereum.stackexchange.com/questions/21483/why-contract-is-not-working-on-test-net-but-work-in-remix
Environment
The text was updated successfully, but these errors were encountered: