Skip to content

Commit

Permalink
fix: πŸ› complete error info for call and send
Browse files Browse the repository at this point in the history
βœ… Closes: #21
  • Loading branch information
siriusyim committed Jan 17, 2024
1 parent cae7dd4 commit fa13fff
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/evm/engine/ether/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ export class EthersEvmEngine implements IEVMEngine {
} catch (error) {
return {
ok: false,
error: `Call contract error: ${error}`,
error: `Call contract error: ${JSON.stringify(error)}`,
}
}
}
Expand Down Expand Up @@ -521,7 +521,7 @@ export class EthersEvmEngine implements IEVMEngine {
} catch (error) {
return {
ok: false,
error: `send error:${error}`,
error: `send error:${JSON.stringify(error)}`,
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/evm/engine/web3/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ export class Web3EvmEngine implements IEVMEngine {
} catch (error) {
return {
ok: false,
error: `Call contract error: ${error}`,
error: `Call contract error: ${JSON.stringify(error)}`,
}
}
}
Expand Down Expand Up @@ -672,7 +672,7 @@ export class Web3EvmEngine implements IEVMEngine {
} catch (error) {
return {
ok: false,
error: `Send to contract error: ${error}`,
error: `Send to contract error: ${JSON.stringify(error)}`,
}
}
}
Expand Down
16 changes: 13 additions & 3 deletions test/evm/error.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import { generateRandomString } from "../tools/utils/randomString"
import * as dotenv from "dotenv"
dotenv.config()

describe.only("Send test(By privateKey)", () => {
it("web3 correct test", async function (this: Context) {
describe("Complete error test", () => {
it("web3 send complete error test", async function (this: Context) {
this.timeout(100000)
const data = [
generateRandomString(10),
Expand All @@ -51,7 +51,12 @@ describe.only("Send test(By privateKey)", () => {
assert.ok((web3Result.error as String).includes("SysErrInsufficientFunds"))
})

it("ethers correct test", async function (this: Context) {
it("web3 call complete error test", async () => {
const web3Meta = await web3Datasets.getDatasetMetadata(0)
assert.ok((web3Meta.error as String).includes("Value must not be zero"))
})

it("ethers send complete error test", async function (this: Context) {
this.timeout(100000)
const data = [
generateRandomString(10),
Expand All @@ -75,4 +80,9 @@ describe.only("Send test(By privateKey)", () => {
assert.equal(ethersResult.ok,false)
assert.ok((ethersResult.error as String).includes("SysErrInsufficientFunds"))
})

it("ethers call complete error test", async () => {
const ethersMeta = await ethersDatasets.getDatasetMetadata(0)
assert.ok((ethersMeta.error as String).includes("Value must not be zero"))
})
})

0 comments on commit fa13fff

Please sign in to comment.