Skip to content

Commit

Permalink
Merge pull request #23 from CityOfZion/CU-86a0q6pde-2
Browse files Browse the repository at this point in the history
Missing FAULT check on calculateFee (neon-dappkit)
  • Loading branch information
melanke authored Oct 30, 2023
2 parents ef71b37 + e7c1849 commit 0e42175
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@cityofzion/neon-dappkit",
"comment": "",
"type": "none"
}
],
"packageName": "@cityofzion/neon-dappkit"
}
29 changes: 28 additions & 1 deletion packages/neon-dappkit/src/NeonInvoker.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function toDecimal(num: number, decimal: number) {
describe('NeonInvoker', function () {
this.timeout(60000)

it('does invokeFuncion', async () => {
it('does invokeFunction', async () => {
const account = new wallet.Account('3bd06d95e9189385851aa581d182f25de34af759cf7f883af57030303ded52b8')
const invoker = await NeonInvoker.init({
rpcAddress: NeonInvoker.TESTNET,
Expand Down Expand Up @@ -345,6 +345,33 @@ describe('NeonInvoker', function () {
}
})

it('can throw an error if testInvoke state is FAULT', async () => {
const invoker = await NeonInvoker.init({
rpcAddress: NeonInvoker.TESTNET,
})

await assert.rejects(
invoker.testInvoke({
invocations: [
{
scriptHash: '0xd2a4cff31913016155e38e474a2c06d08be276cf',
operation: 'transfer',
args: [
{ type: 'Hash160', value: 'NbnjKGMBJzJ6j5PHeYhjJDaQ5Vy5UYu4Fv' },
{ type: 'Integer', value: '100000000' },
{ type: 'Array', value: [] },
],
},
],
}),
{
name: 'Error',
message:
'Execution state is FAULT. Exception: Method "transfer" with 3 parameter(s) doesn\'t exist in the contract 0xd2a4cff31913016155e38e474a2c06d08be276cf.',
},
)
})

it('handles integer return', async () => {
const invoker = await NeonInvoker.init({
rpcAddress: NeonInvoker.TESTNET,
Expand Down

0 comments on commit 0e42175

Please sign in to comment.