Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszradomski committed Mar 25, 2024
1 parent 34d3685 commit b549ffc
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
35 changes: 35 additions & 0 deletions packages/discovery/src/flatten/ParsedFilesManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,5 +260,40 @@ describe(ParsedFilesManager.name, () => {
['L1', 'L2'].sort(),
)
})

it('finds non obvious top-level declaration usage', () => {
const files = [
{
path: 'ImportedAsAll.sol',
content: `
type T1 is uint256;
function f1() public {}
struct S1 { bytes data; }
library L1 { struct S1 { bytes data; } }
library L2 { function f1() public {} }
`,
},
{
path: 'Importing.sol',
content: `
import "./ImportedAsAll.sol";
contract R1 { function r1() public {
L1.S1 memory s;
L2.f1();
f1();
T1 t;
S1 memory s1;
} }
`,
},
]

const manager = ParsedFilesManager.parseFiles(files, EMPTY_REMAPPINGS)
const root = manager.findDeclaration('R1')

expect(root.declaration.referencedDeclaration.sort()).toEqual(
['L1', 'L2', 'S1', 'T1', 'f1'].sort(),
)
})
})
})
6 changes: 5 additions & 1 deletion packages/discovery/src/flatten/flatten.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ describe('flatten', () => {
const CONTRACT2_SOURCE = 'contract C2 { function r3() public {} }'
const CONTRACT3_SOURCE = 'contract C3 { function r4() public {} }'
const CONTRACT4_SOURCE = 'contract C4 { function r4(L1.S1 arg) public {} }'
const LIBRARY_SOURCE = 'library L1 { struct S1 { uint256 x; } }'
const LIBRARY_SOURCE = [
'type T1 is uint256;',
'',
'library L1 { struct S1 { T1 x; } }',
].join('\n')

const remappings = [
'remappedPath1=path1',
Expand Down

0 comments on commit b549ffc

Please sign in to comment.