Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing FAULT check on calculateFee (neon-dappkit) #23

Merged
merged 2 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading