Add solang tests, re-organize sample layouts (#2760)

* Add solang tests, re-organize sample layouts

* Extra lines
This commit is contained in:
Jaco Greeff
2020-10-22 11:39:55 +02:00
committed by GitHub
parent 594376367a
commit b53490bd26
29 changed files with 195 additions and 104 deletions
+11 -65
View File
@@ -19,72 +19,18 @@ function compareInterface (name: string, messageIds: string[]): void {
}
}
interface JSONAbi {
spec: {
messages: {
name: string[] | string
}[]
}
}
describe('Abi', (): void => {
describe('construction', (): void => {
it('initializes from a contract ABI (flipper)', (): void => {
compareInterface('flipper', ['flip', 'get']);
});
it('initializes from a contract ABI (incrementer)', (): void => {
compareInterface('incrementer', ['inc', 'get']);
});
it('initializes from a contract ABI (erc20)', (): void => {
compareInterface('erc20', [
'total_supply',
'balance_of',
'allowance',
'transfer',
'approve',
'transfer_from'
]);
});
it('initializes from a contract ABI (delegator)', (): void => {
compareInterface('delegator', [
'get',
'change',
'switch'
]);
});
it('initializes from a contract ABI (dns)', (): void => {
compareInterface('dns', [
'register',
'set_address',
'transfer',
'get_address'
]);
});
it('initializes from a contract ABI (erc721)', (): void => {
compareInterface('erc721', [
'balance_of',
'owner_of',
'get_approved',
'is_approved_for_all',
'set_approval_for_all',
'approve',
'transfer',
'transfer_from',
'mint',
'burn'
]);
});
it('initializes from a contract ABI (multisig_plain)', (): void => {
compareInterface('multisigPlain', [
'add_owner',
'remove_owner',
'replace_owner',
'change_requirement',
'submit_transaction',
'cancel_transaction',
'confirm_transaction',
'revoke_confirmation',
'invoke_transaction',
'eval_transaction'
]);
Object.entries(abis).forEach(([abiName, abi]) => {
it(`initializes from a contract ABI (${abiName})`, (): void => {
compareInterface(abiName, (abi as JSONAbi).spec.messages.map(({ name }) => Array.isArray(name) ? name[0] : name));
});
});
});