Skip to content

Commit

Permalink
more test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dbcfd committed Apr 6, 2023
1 parent 567116a commit 2b12635
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ exports[`ETH service with mock wallet insufficient funds error 1`] = `
"data": "0x0f017112205d7fcd1a0999befdb062e6762c1f0f902f729b98304a2ef539412f53360d3d6a",
"from": "abcd1234",
"gasLimit": 10000n,
"maxFeePerGas": 2100n,
"maxPriorityFeePerGas": 1100n,
"maxFeePerGas": 2431n,
"maxPriorityFeePerGas": 1210n,
"nonce": 5,
"to": "abcd1234",
}
Expand All @@ -35,8 +35,8 @@ exports[`ETH service with mock wallet insufficient funds error 2`] = `
"data": "0x0f017112205d7fcd1a0999befdb062e6762c1f0f902f729b98304a2ef539412f53360d3d6a",
"from": "abcd1234",
"gasLimit": 10000n,
"maxFeePerGas": 2100n,
"maxPriorityFeePerGas": 1100n,
"maxFeePerGas": 2431n,
"maxPriorityFeePerGas": 1210n,
"nonce": 5,
"to": "abcd1234",
}
Expand Down Expand Up @@ -74,8 +74,8 @@ exports[`ETH service with mock wallet successful mocked transaction 1`] = `
"data": "0x0f017112205d7fcd1a0999befdb062e6762c1f0f902f729b98304a2ef539412f53360d3d6a",
"from": "abcd1234",
"gasLimit": 10000n,
"maxFeePerGas": 2000n,
"maxPriorityFeePerGas": 1000n,
"maxFeePerGas": 2310n,
"maxPriorityFeePerGas": 1100n,
"nonce": 5,
"to": "abcd1234",
}
Expand Down Expand Up @@ -122,7 +122,7 @@ exports[`setGasPrice legacy transaction 1`] = `
"data": "0x0f017112205d7fcd1a0999befdb062e6762c1f0f902f729b98304a2ef539412f53360d3d6a",
"from": "abcd1234",
"gasLimit": 10n,
"gasPrice": 1000n,
"gasPrice": 1100n,
"nonce": undefined,
"to": "abcd1234",
}
Expand All @@ -133,7 +133,7 @@ exports[`setGasPrice legacy transaction 2`] = `
"data": "0x0f017112205d7fcd1a0999befdb062e6762c1f0f902f729b98304a2ef539412f53360d3d6a",
"from": "abcd1234",
"gasLimit": 10n,
"gasPrice": 1100n,
"gasPrice": 1210n,
"nonce": undefined,
"to": "abcd1234",
}
Expand All @@ -144,7 +144,7 @@ exports[`setGasPrice legacy transaction 3`] = `
"data": "0x0f017112205d7fcd1a0999befdb062e6762c1f0f902f729b98304a2ef539412f53360d3d6a",
"from": "abcd1234",
"gasLimit": 10n,
"gasPrice": 1210n,
"gasPrice": 1331n,
"nonce": undefined,
"to": "abcd1234",
}
Expand Down
2 changes: 1 addition & 1 deletion src/services/blockchain/__tests__/eth-bc-service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ describe('ETH service with mock wallet', () => {
>
mockTrySendTransaction
.mockRejectedValueOnce({ code: 'TIMEOUT' })
.mockRejectedValueOnce({ code: 'INSUFFICIENT_FUNDS' })
.mockRejectedValue({ code: 'INSUFFICIENT_FUNDS' })

const cid = CID.parse('bafyreic5p7grucmzx363ayxgoywb6d4qf5zjxgbqjixpkokbf5jtmdj5ni')
await expect(ethBc.sendTransaction(cid)).rejects.toThrow(
Expand Down
12 changes: 4 additions & 8 deletions src/services/blockchain/ethereum/ethereum-blockchain-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,16 @@ async function attempt<T>(
): Promise<T> {
let attempt = 0
while (attempt < max) {
try {
const result = await operation(attempt)
if (result) {
return result
}
} catch (e: any) {
logger.debug(e)
const result = await operation(attempt)
if (result) {
return result
}
attempt++
logger.warn(`Failed to send transaction; ${max - attempt} retries remain`)
await Utils.delay(5000)
}
// All attempts spent
throw new Error('Failed to send transaction')
throw new Error("Failed to send transaction")
}

/**
Expand Down

0 comments on commit 2b12635

Please sign in to comment.