solana-developers / developer-bootcamp-2024

132 stars 31 forks source link

project 2 test fails #6

Open deauthe opened 1 week ago

deauthe commented 1 week ago

made no modification to the test in the project-2 folder.

anchor test --skip-local-validator --skip-deploy

this throws the following error.

Found a 'test' script in the Anchor.toml. Running it as a test suite!

Running test suite: "/Users/deauth/Developer/solana/bootcamp_tut/developer-bootcamp-2024/project-2-voting/anchor/Anchor.toml"

Error: websocket error

> nx run anchor:jest

[2024-10-14T14:05:34.918688000Z INFO  solana_program_test] "voting" SBF program from target/deploy/voting.so, modified 2 minutes, 49 seconds, 768 ms, 448 µs and 834 ns ago
[2024-10-14T14:05:34.918783000Z INFO  solana_program_test] "voting" SBF program from target/deploy/voting.so, modified 2 minutes, 49 seconds, 768 ms, 579 µs and 834 ns ago
[2024-10-14T14:05:34.923179000Z INFO  solana_program_test] Overriding account at 5s3PtT8kLYCv1WEp6dSh3T7EuF35Z6jSu5Cvx4hWG79H
[2024-10-14T14:05:34.989179000Z DEBUG solana_runtime::message_processor::stable_log] Program 5s3PtT8kLYCv1WEp6dSh3T7EuF35Z6jSu5Cvx4hWG79H invoke [1]
[2024-10-14T14:05:34.989602000Z DEBUG solana_runtime::message_processor::stable_log] Program log: Instruction: InitializePoll
[2024-10-14T14:05:34.989782000Z DEBUG solana_runtime::message_processor::stable_log] Program 11111111111111111111111111111111 invoke [2]
[2024-10-14T14:05:34.989812000Z DEBUG solana_runtime::message_processor::stable_log] Program 11111111111111111111111111111111 success
[2024-10-14T14:05:34.989891000Z DEBUG solana_runtime::message_processor::stable_log] Program 5s3PtT8kLYCv1WEp6dSh3T7EuF35Z6jSu5Cvx4hWG79H consumed 14633 of 200000 compute units
[2024-10-14T14:05:34.989904000Z DEBUG solana_runtime::message_processor::stable_log] Program 5s3PtT8kLYCv1WEp6dSh3T7EuF35Z6jSu5Cvx4hWG79H success
 PASS   anchor  tests/bankrun.spec.ts
  ● Console

    console.log
      {
        pollName: 'test-poll',
        pollDescription: 'description',
        pollVotingStart: <BN: 0>,
        pollVotingEnd: <BN: 68dff745>,
        pollOptionIndex: <BN: 0>
      }

      at Object.log (tests/bankrun.spec.ts:38:13)

 FAIL   anchor  tests/basic.spec.ts (16.363 s)
  ● Voting › initializePoll

    thrown: "Exceeded timeout of 5000 ms for a test.
    Add a timeout value to this test to increase the timeout, if this is a long-running test. See https://jestjs.io/docs/api#testname-fn-timeout."

      10 |   const program = anchor.workspace.Voting as Program<Voting>;
      11 |
    > 12 |   it('initializePoll', async () => {
         |   ^
      13 |
      14 |     const [pollAddress] = PublicKey.findProgramAddressSync(
      15 |       [Buffer.from("poll"), new anchor.BN(1).toArrayLike(Buffer, "le", 8)],

      at it (tests/basic.spec.ts:12:3)
      at Object.describe (tests/basic.spec.ts:6:1)

  ● Voting › initialize candidates

    thrown: "Exceeded timeout of 5000 ms for a test.
    Add a timeout value to this test to increase the timeout, if this is a long-running test. See https://jestjs.io/docs/api#testname-fn-timeout."

      29 |   });
      30 |
    > 31 |   it('initialize candidates', async () => {
         |   ^
      32 |     const pollIdBuffer = new anchor.BN(1).toArrayLike(Buffer, "le", 8)
      33 |
      34 |     const [pollAddress] = PublicKey.findProgramAddressSync(

      at it (tests/basic.spec.ts:31:3)
      at Object.describe (tests/basic.spec.ts:6:1)

  ● Voting › vote

    thrown: "Exceeded timeout of 5000 ms for a test.
    Add a timeout value to this test to increase the timeout, if this is a long-running test. See https://jestjs.io/docs/api#testname-fn-timeout."

      56 |   });
      57 |
    > 58 |   it('vote', async () => {
         |   ^
      59 |
      60 |     const tx = await program.methods.vote(
      61 |       new anchor.BN(1),

      at it (tests/basic.spec.ts:58:3)
      at Object.describe (tests/basic.spec.ts:6:1)

Test Suites: 1 failed, 1 passed, 2 total
Tests:       3 failed, 1 passed, 4 total
Snapshots:   0 total
Time:        16.529 s
Ran all test suites.

—————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

 NX   Ran target jest for project anchor (18s)

   ✖  1/1 failed
   ✔  0/1 succeeded [0 read from cache]
jacobcreech commented 1 week ago

Looks like the computer you're running on runs the test slower than mine did, hence the error. The error provides how to fix it https://jestjs.io/docs/api#testname-fn-timeout, but I'll also add here + the readme today.

jacobcreech commented 1 week ago

You'll have to do something to the integration tests such as https://github.com/solana-developers/program-examples/pull/116/files