Add solang tests, re-organize sample layouts (#2760)
* Add solang tests, re-organize sample layouts * Extra lines
This commit is contained in:
@@ -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));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -7,13 +7,11 @@ import path from 'path';
|
||||
import Abi from './Abi';
|
||||
|
||||
import * as testContracts from '../test/contracts';
|
||||
import * as userContracts from '../test/contracts/user';
|
||||
|
||||
const abis: Record<string, any> = { ...testContracts };
|
||||
const userAbis: Record<string, any> = { ...userContracts };
|
||||
|
||||
function compareTypes (name: string): void {
|
||||
const abi = new Abi(abis[name] || userAbis[name]);
|
||||
const abi = new Abi(abis[name]);
|
||||
|
||||
try {
|
||||
const cmpPath = path.join(__dirname, `../test/compare/${name}.test.json`);
|
||||
@@ -32,35 +30,9 @@ function compareTypes (name: string): void {
|
||||
}
|
||||
|
||||
describe('MetaRegistry', (): void => {
|
||||
describe('types', (): void => {
|
||||
it('initializes from a contract ABI (flipper)', (): void => {
|
||||
compareTypes('flipper');
|
||||
});
|
||||
|
||||
it('initializes from a contract ABI (incrementer)', (): void => {
|
||||
compareTypes('incrementer');
|
||||
});
|
||||
|
||||
it('initializes from a contract ABI (erc20)', (): void => {
|
||||
compareTypes('erc20');
|
||||
});
|
||||
|
||||
it('initializes from a contract ABI (dns)', (): void => {
|
||||
compareTypes('dns');
|
||||
});
|
||||
|
||||
it('initializes from a contract ABI (erc721)', (): void => {
|
||||
compareTypes('erc721');
|
||||
});
|
||||
|
||||
it('initializes from a contract ABI (multisig_plain)', (): void => {
|
||||
compareTypes('multisigPlain');
|
||||
});
|
||||
});
|
||||
|
||||
describe('user ABIs', (): void => {
|
||||
it('initializes from a contract ABI (withString)', (): void => {
|
||||
compareTypes('withString');
|
||||
Object.keys(abis).forEach((abiName) => {
|
||||
it(`initializes from a contract ABI (${abiName})`, (): void => {
|
||||
compareTypes(abiName);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user