Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error running replica tests locally #260

Open
tomijaga opened this issue Jan 3, 2025 · 5 comments
Open

Error running replica tests locally #260

tomijaga opened this issue Jan 3, 2025 · 5 comments

Comments

@tomijaga
Copy link
Contributor

tomijaga commented Jan 3, 2025

Hey @ZenVoich,
I'm trying to run some tests using the pocket-ic but i keep running into this issue.

nx0 [Error]: The PocketIC binary took too long to start. Please try again.
    at x7.poll.intervalMs (file:///Users/dire.sol/.nvm/versions/node/v22.4.0/lib/node_modules/ic-mops/cli.js:145:19662)
    at async Timeout.Y [as _onTimeout] (file:///Users/dire.sol/.nvm/versions/node/v22.4.0/lib/node_modules/ic-mops/cli.js:136:202169)

Node.js v22.4.0
make: *** [test-replica] Error 1

I've also tried running the tests using --replica dfx but it returns a similar error

...
oid 0;class cx0 extends Error{constructor($){super(`There was an error starting the PocketIC Binary.
...

Error: Process exited with code 255
    at ChildProcess.w (file:///Users/dire.sol/.nvm/versions/node/v22.4.0/lib/node_modules/ic-mops/cli.js:136:30554)
    at ChildProcess.emit (node:events:520:28)
    at maybeClose (node:internal/child_process:1105:16)
    at Socket.<anonymous> (node:internal/child_process:457:11)
    at Socket.emit (node:events:520:28)
    at Pipe.<anonymous> (node:net:339:12) {
  code: 255,
  signal: null,
  stdout: [Getter],
  stderr: [Getter]
}

Node.js v22.4.0

This is only an issue when i run the tests locally. It works just fine when it's deployed as a github actions job.

Do you think it might be an issue with my device or configurations?
I use an M1 Macbook running Sequoia 15.1 MacOs.
Here's a link to the tests and the mops command: mops test --mode replica --replica pocket-ic .replica.

Mops version

❯ mops -v                                                                                                                                 ─╯
CLI 1.2.0
API 1.3
@ZenVoich
Copy link
Owner

ZenVoich commented Jan 3, 2025

Hey @tomijaga , I tried on my M3 mac (15.1.1) without errors

mops test --mode replica --replica pocket-ic .replica -r verbose
Test files:
• tests/Variant.Replica.mo
• tests/Txs.Replica.mo
==================================================
Running tests/Variant.Replica.mo (replica)
 PASS
 • searching with nested variant fields
   ✓ search for variants by their tags
   ✓ search via indexed fields
   ✓ search via non indexed fields
 PASS
--------------------------------------------------
Running tests/Txs.Replica.mo (replica)
 PASS
 • testing txs db with queries
     stdout actual_query_resolution: #And([#Operation("btype", #eq(#Text("1mint")))])
     stdout expected_query_resolution: #And([#Operation("btype", #eq(#Text("1mint")))])
   ✓ get_txs() with btype = '1mint'
     stdout actual_query_resolution: #And([#Operation("tx.amt", #gte(#Nat(355)))])
     stdout expected_query_resolution: #And([#Operation("tx.amt", #gte(#Nat(355)))])
   ✓ get_txs() with tx.amt > 355
     stdout actual_query_resolution: #And([#Operation("btype", #eq(#Text("1xfer")))])
     stdout expected_query_resolution: #And([#Operation("btype", #eq(#Text("1xfer")))])
   ✓ get_txs() with btype = '1xfer'
     stdout actual_query_resolution: #And([#Operation("btype", #eq(#Text("2approve")))])
     stdout expected_query_resolution: #And([#Operation("btype", #eq(#Text("2approve")))])
   ✓ get_txs() with btype = '2approve'
     stdout actual_query_resolution: #Or([#Operation("btype", #eq(#Text("1burn"))), #Operation("btype", #eq(#Text("1xfer")))])
     stdout expected_query_resolution: #Or([#Operation("btype", #eq(#Text("1burn"))), #Operation("btype", #eq(#Text("1xfer")))])
   ✓ get_txs() with btype = '1burn' or '1xfer'
     stdout actual_query_resolution: #And([#Operation("tx.to.owner", #eq(#Principal(dnnxm-gse3f-chys6-hdjy5-m33kt-ds7s6-25pv2-gm2cx-rf5s5-udp62-e6o)))])
     stdout expected_query_resolution: #And([#Operation("tx.to.owner", #eq(#Principal(dnnxm-gse3f-chys6-hdjy5-m33kt-ds7s6-25pv2-gm2cx-rf5s5-udp62-e6o)))])
   ✓ get_txs() with the first principal as the recipient
     stdout actual_query_resolution: #And([#Operation("tx.from.owner", #eq(#Principal(xhyiv-f77ls-apxvy-ohl7i-unoi6-awinz-mr74f-7hc7r-7ccr5-dqpk6-u4q)))])
     stdout expected_query_resolution: #And([#Operation("tx.from.owner", #eq(#Principal(xhyiv-f77ls-apxvy-ohl7i-unoi6-awinz-mr74f-7hc7r-7ccr5-dqpk6-u4q)))])
   ✓ get_txs() with the 2nd principal as the sender
     stdout actual_query_resolution: #And([#Operation("tx.spender.owner", #eq(#Principal(dxalh-crfl2-23xdy-qafp5-4jvwm-2wrjc-vui65-mbniy-2ich2-ck2pc-vg4)))])
     stdout expected_query_resolution: #And([#Operation("tx.spender.owner", #eq(#Principal(dxalh-crfl2-23xdy-qafp5-4jvwm-2wrjc-vui65-mbniy-2ich2-ck2pc-vg4)))])
   ✓ get_txs() with the 3rd principal as the spender
     stdout actual_query_resolution: #Or([#Operation("tx.to.owner", #eq(#Principal(xhyiv-f77ls-apxvy-ohl7i-unoi6-awinz-mr74f-7hc7r-7ccr5-dqpk6-u4q))), #Operation("tx.from.owner", #eq(#Principal(xhyiv-f77ls-apxvy-ohl7i-unoi6-awinz-mr74f-7hc7r-7ccr5-dqpk6-u4q))), #Operation("tx.spender.owner", #eq(#Principal(xhyiv-f77ls-apxvy-ohl7i-unoi6-awinz-mr74f-7hc7r-7ccr5-dqpk6-u4q)))])
     stdout expected_query_resolution: #Or([#Operation("tx.to.owner", #eq(#Principal(xhyiv-f77ls-apxvy-ohl7i-unoi6-awinz-mr74f-7hc7r-7ccr5-dqpk6-u4q))), #Operation("tx.from.owner", #eq(#Principal(xhyiv-f77ls-apxvy-ohl7i-unoi6-awinz-mr74f-7hc7r-7ccr5-dqpk6-u4q))), #Operation("tx.spender.owner", #eq(#Principal(xhyiv-f77ls-apxvy-ohl7i-unoi6-awinz-mr74f-7hc7r-7ccr5-dqpk6-u4q)))])
   ✓ get_txs() involving the 2nd principal, sort by ('ts', #Ascending)
     stdout actual_query_resolution: #And([#Operation("tx.amt", #gte(#Nat(2))), #Operation("tx.amt", #lte(#Nat(49)))])
     stdout expected_query_resolution: #And([#Operation("tx.amt", #gte(#Nat(2))), #Operation("tx.amt", #lte(#Nat(49)))])
   ✓ get_txs() with 'amt' less than 50 and greater than 1
     stdout actual_query_resolution: #Or([#Operation("tx.to.owner", #eq(#Principal(xhyiv-f77ls-apxvy-ohl7i-unoi6-awinz-mr74f-7hc7r-7ccr5-dqpk6-u4q))), #Operation("tx.to.owner", #eq(#Principal(dnnxm-gse3f-chys6-hdjy5-m33kt-ds7s6-25pv2-gm2cx-rf5s5-udp62-e6o))), #Operation("tx.from.owner", #eq(#Principal(xhyiv-f77ls-apxvy-ohl7i-unoi6-awinz-mr74f-7hc7r-7ccr5-dqpk6-u4q))), #Operation("tx.from.owner", #eq(#Principal(dnnxm-gse3f-chys6-hdjy5-m33kt-ds7s6-25pv2-gm2cx-rf5s5-udp62-e6o))), #Operation("tx.spender.owner", #eq(#Principal(xhyiv-f77ls-apxvy-ohl7i-unoi6-awinz-mr74f-7hc7r-7ccr5-dqpk6-u4q))), #Operation("tx.spender.owner", #eq(#Principal(dnnxm-gse3f-chys6-hdjy5-m33kt-ds7s6-25pv2-gm2cx-rf5s5-udp62-e6o)))])
     stdout expected_query_resolution: #Or([#Operation("tx.to.owner", #eq(#Principal(xhyiv-f77ls-apxvy-ohl7i-unoi6-awinz-mr74f-7hc7r-7ccr5-dqpk6-u4q))), #Operation("tx.to.owner", #eq(#Principal(dnnxm-gse3f-chys6-hdjy5-m33kt-ds7s6-25pv2-gm2cx-rf5s5-udp62-e6o))), #Operation("tx.from.owner", #eq(#Principal(xhyiv-f77ls-apxvy-ohl7i-unoi6-awinz-mr74f-7hc7r-7ccr5-dqpk6-u4q))), #Operation("tx.from.owner", #eq(#Principal(dnnxm-gse3f-chys6-hdjy5-m33kt-ds7s6-25pv2-gm2cx-rf5s5-udp62-e6o))), #Operation("tx.spender.owner", #eq(#Principal(xhyiv-f77ls-apxvy-ohl7i-unoi6-awinz-mr74f-7hc7r-7ccr5-dqpk6-u4q))), #Operation("tx.spender.owner", #eq(#Principal(dnnxm-gse3f-chys6-hdjy5-m33kt-ds7s6-25pv2-gm2cx-rf5s5-udp62-e6o)))])
   ✓ get_txs() involving the first 2 principals
     stdout actual_query_resolution: #And([#Operation("btype", #eq(#Text("1xfer"))), #Operation("tx.amt", #gte(#Nat(11)))])
     stdout expected_query_resolution: #And([#Operation("btype", #eq(#Text("1xfer"))), #Operation("tx.amt", #gte(#Nat(11)))])
   ✓ get_txs() with 'btype' = '1xfer' and 'amt' > 10
 • testing txs db with pagination
   ✓ get_txs() with btype = '1mint'
   ✓ get_txs() with tx.amt > 355
   ✓ get_txs() with btype = '1xfer'
   ✓ get_txs() with btype = '2approve'
   ✓ get_txs() with btype = '1burn' or '1xfer'
   ✓ get_txs() with the first principal as the recipient
   ✓ get_txs() with the 2nd principal as the sender
   ✓ get_txs() with the 3rd principal as the spender
   ✓ get_txs() involving the 2nd principal, sort by ('ts', #Ascending)
   ✓ get_txs() with 'amt' less than 50 and greater than 1
   ✓ get_txs() involving the first 2 principals
   ✓ get_txs() with 'btype' = '1xfer' and 'amt' > 10
 • testing txs db with sorting
   ✓ get_txs() with btype = '1mint'
   ✓ get_txs() with tx.amt > 355
   ✓ get_txs() with btype = '1xfer'
   ✓ get_txs() with btype = '2approve'
   ✓ get_txs() with btype = '1burn' or '1xfer'
   ✓ get_txs() with the first principal as the recipient
   ✓ get_txs() with the 2nd principal as the sender
   ✓ get_txs() with the 3rd principal as the spender
   ✓ get_txs() involving the 2nd principal, sort by ('ts', #Ascending)
   ✓ get_txs() with 'amt' less than 50 and greater than 1
   ✓ get_txs() involving the first 2 principals
   ✓ get_txs() with 'btype' = '1xfer' and 'amt' > 10
 • testing txs db with sorting and pagination
   ✓ get_txs() with btype = '1mint'
   ✓ get_txs() with tx.amt > 355
   ✓ get_txs() with btype = '1xfer'
   ✓ get_txs() with btype = '2approve'
   ✓ get_txs() with btype = '1burn' or '1xfer'
   ✓ get_txs() with the first principal as the recipient
   ✓ get_txs() with the 2nd principal as the sender
   ✓ get_txs() with the 3rd principal as the spender
   ✓ get_txs() involving the 2nd principal, sort by ('ts', #Ascending)
   ✓ get_txs() with 'amt' less than 50 and greater than 1
   ✓ get_txs() involving the first 2 principals
   ✓ get_txs() with 'btype' = '1xfer' and 'amt' > 10
 PASS
==================================================
Tests passed
Done in 25.70s, passed 51

I'm not sure how to fix this, you may try reinstalling mops with clearing cache:

curl -fsSL cli.mops.one/install.sh | sh
mops cache clean
mops install
mops test ...

@tomijaga
Copy link
Contributor Author

tomijaga commented Jan 4, 2025

I tried your suggestion to reinstall mops but I still got the same error

I seem to have missed some information from the error message in the previous post.
I've added top section of the error message below. Maybe it could help in finding the root cause.
Specifically, this line - Could not find the PocketIC binary. The PocketIC binary could not be found at $ {$}. Please try installing @hadronous/pic again.

❯ /Users/dire.sol/.nvm/versions/node/v22.4.0/bin/mops  test --mode replica --replica pocket-ic variant ─╯
Test files:
• tests/Variant.Replica.mo
==================================================
file:///Users/dire.sol/.nvm/versions/node/v22.4.0/lib/node_modules/ic-mops/cli.js:145
${$.stack}`,{cause:$})}}sx0.BinStartMacOSArmError=px0;class ix0 extends Error{constructor($){super(`Could not find the PocketIC binary. The PocketIC binary could not be found at ${$}. Please try installing @hadronous/pic again.`)}}sx0.BinNotFoundError=ix0;class nx0 extends Error{constructor(){super("The PocketIC binary took too long to start. Please try again.")}}sx0.BinTimeoutError=nx0;class ax0 extends Error{constructor(){super("A request to the PocketIC server timed out.")}}sx0.ServerRequestTimeoutError=ax0;class rx0 extends Error{constructor(){super("This PocketIC instance has been torn down. Please create a new instance before interacting further with PocketIC.")}}sx0.InstanceDeletedError=rx0;class ox0 extends Error{constructor(){super("The provided subnet configuration is invalid. At least one subnet must be configured and the number of both application and system subnets must be at least 0 (non-negative).")}}sx0.TopologyValidationError=ox0});var 
...
X_0=L((J_0)=>Z=Array.from({length:xz1($)+1}),X=_z1($[J],Z,J);return gz1(X,J)},xz1=({stdio:$})=>Array.isArray($)?Math.max($.length,t4.length):t4.length,_z1=($,J,Z)=>N8($)?Sz1($,J,Z):J.fill($),Sz1=($,J,Z)=>{for(let X of Object.keys($).sort(vz1))for(let z of kz1(X,Z,J))J[z]=$[X];return J},vz1=($,J)=>bz0($)<bz0(J)?1:-1,bz0=($)=>{if($==="stdout"||$==="stderr")return 0;return $==="all"?2:1},kz1=($,J,Z)=>{if($==="ipc")return[Z.length-1];const X=xS($);if(X===void 0||X===0)throw new TypeError(`"${J}.${$}" is invalid.
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            

nx0 [Error]: The PocketIC binary took too long to start. Please try again.
    at x7.poll.intervalMs (file:///Users/dire.sol/.nvm/versions/node/v22.4.0/lib/node_modules/ic-mops/cli.js:145:19662)
    at async Timeout.Y [as _onTimeout] (file:///Users/dire.sol/.nvm/versions/node/v22.4.0/lib/node_modules/ic-mops/cli.js:136:202169)

Node.js v22.4.0

@ZenVoich
Copy link
Owner

ZenVoich commented Jan 4, 2025

Specifically, this line - Could not find the PocketIC binary. The PocketIC binary could not be found at $ {$}. Please try installing @hadronous/pic again.

I see it's just a file with all errors, but the thrown one is The PocketIC binary took too long to start. Please try again

How long does it take to run manually? $(mops toolchain bin pocket-ic)
Output should be like this

2025-01-04T07:30:10.667727Z  INFO pocket_ic_server: The PocketIC server is listening on port 50153

@tomijaga
Copy link
Contributor Author

tomijaga commented Jan 4, 2025

It's pretty fast, takes about 3s to print out the server message.
time $(mops toolchain bin pocket-ic) 0.22s user 0.35s system 24% cpu 2.330 total

While the replica tests take about 45s
make test-replica 90.61s user 12.52s system 230% cpu 44.654 total

@ZenVoich
Copy link
Owner

ZenVoich commented Jan 7, 2025

Please try npm i -g [email protected] with pocket-ic 4.0.0
If not helped - npm i -g [email protected] with pocket-ic 6.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants