From e211be41fd87c3ec6cf85d30c0fb92dc53bcf3de Mon Sep 17 00:00:00 2001 From: Alberto Lerda Date: Thu, 12 Oct 2023 11:04:49 +0100 Subject: [PATCH] increase codecov --- pkg/ethereum/src/plugins.ts | 2 -- pkg/ethereum/test/plugin.ts | 31 +++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/pkg/ethereum/src/plugins.ts b/pkg/ethereum/src/plugins.ts index 2bc61093..0b19008a 100644 --- a/pkg/ethereum/src/plugins.ts +++ b/pkg/ethereum/src/plugins.ts @@ -54,8 +54,6 @@ export const execute = async ( addresses.map((addr) => web3.eth.getBalance(addr as string)) ); return ctx.pass(balances.map((b) => b.toString()) as JsonableArray); - } else { - throw new Error('Undefined argument'); } } if (kind === EthereumRequestKind.EthereumBytes) { diff --git a/pkg/ethereum/test/plugin.ts b/pkg/ethereum/test/plugin.ts index 596ee513..c244ac8f 100644 --- a/pkg/ethereum/test/plugin.ts +++ b/pkg/ethereum/test/plugin.ts @@ -5,6 +5,19 @@ import { astify, execute } from '@slangroom/ethereum'; const test = anyTest as TestFn<{ web3: Web3 }>; +test('unknown token', async (t) => { + const { errors } = astify('ouisdhfaiuo'); + if(!errors) { + t.fail() + return; + } + const { errors: errors2 } = astify('read read read'); + if(!errors2) { + t.fail() + return; + } + t.truthy(true); +}) test('read the ethereum nonce', async (t) => { const { ast, errors } = astify('read the ethereum nonce'); if (errors) { @@ -121,6 +134,24 @@ test('Erc20 method without arg', async (t) => { } }); +test('erc20 with invalid address', async (t) => { + const { ast, errors } = astify(`read the erc20 symbol`); + if (errors) { + t.fail(errors?.toString()); + return; + } + const ctx = new PluginContextTest('http://78.47.38.223:9485', { + sc: '0x720765775bb85EAAa08BB74442F106d3ffA03', + }); + try { + await execute(ctx, ast); + } catch(e) { + t.truthy(true); + return; + } + t.falsy(true); +}); + /*test("Erc20 method with arg", async (t) => { const { ast, errors } = astify("read the erc20 balance"); if (errors) {