Skip to content

Commit

Permalink
increase codecov
Browse files Browse the repository at this point in the history
  • Loading branch information
albertolerda committed Oct 12, 2023
1 parent 33d2a75 commit e211be4
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
2 changes: 0 additions & 2 deletions pkg/ethereum/src/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
31 changes: 31 additions & 0 deletions pkg/ethereum/test/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit e211be4

Please sign in to comment.