ironaddicteddog/anchor-escrow

Failing test

Closed this issue · 4 comments

teseo commented

Before anything, I would like to appreciate this code and the article related.

I'm following line by line the article but I'm getting this error when running the second test Initialize program state

 anchor-escrow
    ✔ Initialize program state (5011ms)
Transaction simulation failed: Error processing Instruction 1: custom program error: 0xbc4
    Program 11111111111111111111111111111111 invoke [1]
    Program 11111111111111111111111111111111 success
    Program CL5TkCxmuTq47U2WGtTGhp3rPEVsYgDewXUyRJfqACzK invoke [1]
    Program log: Instruction: Initialize
    Program log: Custom program error: 0xbc4
    Program CL5TkCxmuTq47U2WGtTGhp3rPEVsYgDewXUyRJfqACzK consumed 6964 of 200000 compute units
    Program CL5TkCxmuTq47U2WGtTGhp3rPEVsYgDewXUyRJfqACzK failed: custom program error: 0xbc4
    1) Initialize escrow
    ✔ Exchange escrow state
    ✔ Initialize escrow and cancel escrow


  3 passing (5s)
  1 failing

  1) anchor-escrow
       Initialize escrow:
     Error: 3012: The program expected this account to be already initialized
      at Function.parse (node_modules/@project-serum/anchor/src/error.ts:41:14)
      at Object.rpc [as initialize] (node_modules/@project-serum/anchor/src/program/namespace/rpc.ts:32:42)
      at processTicksAndRejections (internal/process/task_queues.js:95:5)

Any help would be much appreciated.

Hi, let me reproduce this issue. Which network / anchor version are you using?

teseo commented

Hi @ironaddicteddog many thanks for your response. I'm using localnet and anchor-cli 0.20.1

@teseo I think you forgot to switch the network in the tests. You need to change the providers.

describe('anchor-escrow', () => {
  // const commitment: Commitment = 'processed';
  // const connection = new Connection('https://rpc-mainnet-fork.dappio.xyz', { commitment, wsEndpoint: 'wss://rpc-mainnet-fork.dappio.xyz/ws' });
  // const options = anchor.Provider.defaultOptions();
  // const wallet = NodeWallet.local();
  // const provider = new anchor.Provider(connection, wallet, options);

  // anchor.setProvider(provider);

  // Local Network
  const provider = anchor.Provider.env();
  anchor.setProvider(provider);

Comment out the Main net part and add a localnet for testing purposes

teseo commented

thanks @arunavo4