diff --git a/src/token-processor/stacks-node/stacks-node-rpc-client.ts b/src/token-processor/stacks-node/stacks-node-rpc-client.ts index 871247be..824891a9 100644 --- a/src/token-processor/stacks-node/stacks-node-rpc-client.ts +++ b/src/token-processor/stacks-node/stacks-node-rpc-client.ts @@ -138,7 +138,7 @@ export class StacksNodeRpcClient { `Runtime error while calling read-only function ${functionName}` ); } else if (result.cause.includes('NoSuchContract')) { - throw new SmartContractClarityError( + throw new RetryableJobError( `Contract not available yet when calling read-only function ${functionName}` ); } diff --git a/tests/token-queue/process-token-job.test.ts b/tests/token-queue/process-token-job.test.ts index 5d79c93e..14627e3f 100644 --- a/tests/token-queue/process-token-job.test.ts +++ b/tests/token-queue/process-token-job.test.ts @@ -912,4 +912,33 @@ describe('ProcessTokenJob', () => { expect(host).toBeUndefined(); }); }); + + test('Contract not found gets retried', async () => { + const nodeUrl = `http://${ENV.STACKS_NODE_RPC_HOST}:${ENV.STACKS_NODE_RPC_PORT}`; + const [tokenJob] = await insertAndEnqueueTestContractWithTokens( + db, + 'ABCD.test-nft', + DbSipNumber.sip009, + 1n + ); + + const mockResponse = { + okay: false, + cause: `Unchecked(NoSuchContract("ABCD.test-nft"))`, + }; + const agent = new MockAgent(); + agent.disableNetConnect(); + agent + .get(nodeUrl) + .intercept({ + path: `/v2/contracts/call-read/ABCD/test-nft/get-token-uri`, + method: 'POST', + }) + .reply(200, mockResponse); + setGlobalDispatcher(agent); + + await expect(new ProcessTokenJob({ db, job: tokenJob }).handler()).rejects.toThrow( + RetryableJobError + ); + }); }); diff --git a/tests/token-queue/stacks-node-rpc-client.test.ts b/tests/token-queue/stacks-node-rpc-client.test.ts index 0877b670..506ab664 100644 --- a/tests/token-queue/stacks-node-rpc-client.test.ts +++ b/tests/token-queue/stacks-node-rpc-client.test.ts @@ -13,7 +13,6 @@ import { StacksNodeRpcClient } from '../../src/token-processor/stacks-node/stack import { StacksNodeJsonParseError, StacksNodeHttpError, - SmartContractClarityError, } from '../../src/token-processor/util/errors'; describe('StacksNodeRpcClient', () => { @@ -70,7 +69,7 @@ describe('StacksNodeRpcClient', () => { setGlobalDispatcher(agent); await expect(client.readStringFromContract('get-token-uri', [])).rejects.toThrow( - SmartContractClarityError + RetryableJobError ); });