Skip to content

Commit

Permalink
fix(contract): don't duplicate NoSuchContractFunctionError message
Browse files Browse the repository at this point in the history
  • Loading branch information
davidyuk committed Jan 22, 2024
1 parent 6dc614e commit 2f3bba5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/contract/Contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ class Contract<M extends ContractMethodsBase> {
arguments: [], name: 'init', payable: false, returns: 'unit', stateful: true,
};
}
throw new NoSuchContractFunctionError(`Function ${name} doesn't exist in contract`);
throw new NoSuchContractFunctionError(name);
}

/**
Expand Down
6 changes: 6 additions & 0 deletions test/integration/contract-aci.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
hash,
AE_AMOUNT_FORMATS,
Tag,
NoSuchContractFunctionError,
} from '../../src';
import { getSdk } from '.';
import {
Expand Down Expand Up @@ -294,6 +295,11 @@ describe('Contract instance', () => {
await contract.intFn(2, { callStatic: true });
});

it('fails with error if function missed', async () => {
await expect(testContract.$call('notExisting', []))
.to.be.rejectedWith(NoSuchContractFunctionError, 'Function notExisting doesn\'t exist in contract');
});

it('gets actual options from AeSdkBase', async () => {
const [address1, address2] = aeSdk.addresses();
let { result } = await testContract.intFn(2);
Expand Down

0 comments on commit 2f3bba5

Please sign in to comment.