Skip to content

Commit

Permalink
test(wip): refactor tests to for ABI bytes[]
Browse files Browse the repository at this point in the history
  • Loading branch information
CJ42 committed May 15, 2024
1 parent 758730c commit f3d00d3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 18 deletions.
15 changes: 6 additions & 9 deletions src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -507,8 +507,7 @@ describe('Running @erc725/erc725.js tests...', () => {
returnData: [
{
key: '0x5ef83ad9559033e6e941db7d7c495acdce616347d28e90c7ce47cbfcfcad3bc5',
value:
'0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000',
value: '0x',
},
],
},
Expand Down Expand Up @@ -544,17 +543,15 @@ describe('Running @erc725/erc725.js tests...', () => {
{
key: '0x48643a15ac5407a175674ab0f8c92df5ae90694dac72ebf0a058fb2599e3b06a', // MyURL
value:
'0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000035697066733a2f2f516d6245724b6833466a73415236596a73546a485a4e6d364d6344703661527438324674637639414a4a765a62640000000000000000000000',
'0x697066733a2f2f516d6245724b6833466a73415236596a73546a485a4e6d364d6344703661527438324674637639414a4a765a62640000000000000000000000',
},
{
key: '0x74ac2555c10b9349e78f0000b74a88c43bcf691bd7a851f6603cb1868f6fc147', // LSP12IssuedAssetsMap:b74a88C43BCf691bd7A851f6603cb1868f6fc147
value:
'0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000141098603b193d276f5fa176cc02007b609f9dae6b000000000000000000000000',
value: '0x1098603b193d276f5fa176cc02007b609f9dae6b',
},
{
key: '0xeafec4d89fa9619884b600005ef83ad9559033e6e941db7d7c495acdce616347', // SupportedStandards:LSP3Profile
value:
'0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000045ef83ad900000000000000000000000000000000000000000000000000000000',
value: '0x5ef83ad9',
},
],
},
Expand All @@ -580,8 +577,8 @@ describe('Running @erc725/erc725.js tests...', () => {
name: 'LSP12IssuedAssetsMap:<address>',
key: '0x74ac2555c10b9349e78f0000<address>',
keyType: 'Mapping',
valueContent: 'Address',
valueType: 'address',
valueType: '(bytes4,uint128)',
valueContent: '(Bytes4,Number)',
},
],
'0x24464DbA7e7781a21eD86133Ebe88Eb9C0762620', // result is mocked so we can use any address
Expand Down
10 changes: 5 additions & 5 deletions src/lib/getSchemaElement.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ describe('getSchemaElement', () => {
name: 'LSP12IssuedAssetsMap:<address>',
key: '0x74ac2555c10b9349e78f0000<address>',
keyType: 'Mapping',
valueType: 'bytes',
valueContent: 'Mixed',
valueType: '(bytes4,uint128)',
valueContent: '(Bytes4,Number)',
},
{
name: 'ARandomKey',
key: '0x7cf0c8053453d0353fdbad6a48e68966b35dd13cb3a62e7b75009dc5035b80c0',
keyType: 'Singleton',
valueContent: 'JSONURL',
valueType: 'bytes',
valueContent: 'JSONURL',
},
];

Expand All @@ -71,8 +71,8 @@ describe('getSchemaElement', () => {
name: 'LSP12IssuedAssetsMap:2ab3903c6e5815f4bc2a95b7f3b22b6a289bacac',
key: '0x74ac2555c10b9349e78f00002ab3903c6e5815f4bc2a95b7f3b22b6a289bacac',
keyType: 'Mapping',
valueType: 'bytes',
valueContent: 'Mixed',
valueType: '(bytes4,uint128)',
valueContent: '(Bytes4,Number)',
},
);
});
Expand Down
6 changes: 2 additions & 4 deletions test/mockProviders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,13 @@ export class HttpProvider {
const foundElement = this.returnData.find((element) => {
return element.key === requestedKey;
});
return foundElement
? abiCoder.decodeParameter('bytes[]', foundElement.value)[0] // we need to decode the keys as the values provided to the mock are already bytes[] encoded (as it was made for "single item" request mode)
: '0x';
return foundElement ? foundElement.value : '0x';
});

results.push({
jsonrpc: '2.0',
id: payload[index].id,
result: abiCoder.encodeParameter('bytes[]', decodedResult),
result: decodedResult,
});
}
break;
Expand Down

0 comments on commit f3d00d3

Please sign in to comment.