I use Truffle to test a contract. When i use Contract.deployed() and i fetch address, for example :
- In a first test, the contract's address is 0x07D899846146b3503dE9D9Dc36B94C2e428eA434
- In a second one, the contract's address is 0xF79f3B32b78ebD07B2E661b52e9CF374e311f1d5
Another problem is that it seems that on each time i test the contract, it's state is reinitialized.
It seems that Contract.deployed()
create works like Contract.new()
, it create a new instance of the contract for each test.
Which can cause this problem ?
truffle test
completes, the next time you run it, the initial migration takes place again and new contracts are deployed. If you've left Ganache opened from the previous execution oftruffle test
, then those new instances will be deployed at different addresses.