2021-10-20 17:12:07 +02:00
|
|
|
const { readAddressAsContract } = require('./contract-utils');
|
|
|
|
|
|
|
|
describe('Contract Utils', () => {
|
|
|
|
it('checks is an address is a contract address or not', async () => {
|
|
|
|
let mockEthQuery = {
|
|
|
|
getCode: () => {
|
|
|
|
return '0xa';
|
|
|
|
},
|
|
|
|
};
|
|
|
|
const { isContractAddress } = await readAddressAsContract(
|
|
|
|
mockEthQuery,
|
|
|
|
'0x76B4aa9Fc4d351a0062c6af8d186DF959D564A84',
|
|
|
|
);
|
|
|
|
expect(isContractAddress).toStrictEqual(true);
|
|
|
|
|
|
|
|
mockEthQuery = {
|
|
|
|
getCode: () => {
|
|
|
|
return '0x';
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2022-07-31 20:26:40 +02:00
|
|
|
const { isContractAddress: isNotContractAddress } =
|
|
|
|
await readAddressAsContract(
|
|
|
|
mockEthQuery,
|
|
|
|
'0x76B4aa9Fc4d351a0062c6af8d186DF959D564A84',
|
|
|
|
);
|
2021-10-20 17:12:07 +02:00
|
|
|
expect(isNotContractAddress).toStrictEqual(false);
|
|
|
|
});
|
|
|
|
});
|