Finishing Wallet

For this one, I’m getting an error stating that Wallet has not been deployed to detected network (network/artifact mismatch). I thought I followed all of Philip’s directions this time. Plus, there was no error for the Wallet migration execution. Here’s the git: https://github.com/aelkins3/DEX201.git. Help!!!

1 Like

this time your not deploying to thr correct network. run truffle migrate reset then when this is done try to execute those commands

1 Like

Hi, before watching ‘Better migration’ lecture I had decided to write a test case in order to see whether the token gets added as asserted by using addToken function in our code, here it is for you to try out for yourself and I hope it contribute your testing knowledges as well.

const Wallet = artifacts.require("Wallet");
const Link = artifacts.require("Link");

contract("Wallet", (accounts) => {
  const owners = [accounts[0], accounts[1], accounts[2]];
  const NUM_CONFIRMATIONS_REQUIRED = 2;
  let wallet;
  let link;

  before(async () => {
    wallet = await Wallet.deployed();
    link = await Link.deployed();
  });

  console.log( "link artifact:", link );
  console.log( "1 ether:", (1*10)**18 );

  describe("user adds LINK token to his account", async () => {
    const ticker = "LINK";
    const bytes32Value = web3.utils.fromUtf8(ticker);
    let logTokenAdded;
    before("adds token", async () => {
      logTokenAdded = await wallet.addToken(bytes32Value, link.address);
      // console.log("token added:", logTokenAdded);
    });
    it("should pass if bytes32 value in tokenMapping.tokenAddress and link.address", async () => {
      const tickerTokenAddress = link.address;
      const mappedAddress = await wallet.tokenMapping(bytes32Value).then((res)=>{
        return Object(res.tokenAddress).toString();
      });
      console.log({
       "given ticker": ticker,
       "given ticker's bytes32 val": bytes32Value,
       "added ticker's mapped data": await wallet.tokenMapping(bytes32Value),
       "tokenAddress mapped to the given ticker": await mappedAddress,
       "ticker in tokenList's first (0) element": await wallet.tokenList(0),
      });

      assert.equal(mappedAddress, tickerTokenAddress);
    });
  });
});

Note, the lines below are not necessary especially for this code, they are just from my testing template, you can use them for other tests too.

const owners = [accounts[0], accounts[1], accounts[2]]; 
const NUM_CONFIRMATIONS_REQUIRED = 2;
1 Like