Skip to content

Commit 8dbd9a4

Browse files
arthcpaxic
authored andcommitted
Add test cases to cover new code
1 parent e3c5f10 commit 8dbd9a4

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

test/linker.js

+22
Original file line numberDiff line numberDiff line change
@@ -166,4 +166,26 @@ tape('Linking', function (t) {
166166
st.ok(bytecode.indexOf('_') < 0);
167167
st.end();
168168
});
169+
170+
t.test('link properly by providing link reference', function (st) {
171+
/*
172+
'lib.sol': 'library L { function f() public returns (uint) { return 7; } }',
173+
'cont.sol': 'import "lib.sol"; contract x { function g() public { L.f(); } }'
174+
*/
175+
var bytecode = '608060405234801561001057600080fd5b5061011f806100206000396000f300608060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063e2179b8e146044575b600080fd5b348015604f57600080fd5b5060566058565b005b73__lib.sol:L_____________________________6326121ff06040518163ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040160206040518083038186803b15801560b757600080fd5b505af415801560ca573d6000803e3d6000fd5b505050506040513d602081101560df57600080fd5b8101908080519060200190929190505050505600a165627a7a72305820ea2f6353179c181d7162544d637b7fe2d9e8da9803a0e2d9eafc2188d1d59ee30029';
176+
bytecode = linker.linkBytecode(bytecode, { 'lib.sol:L': '0x123456' }, { 'lib.sol:L': [ { start: 122, length: 20 } ] });
177+
st.ok(bytecode.indexOf('_') < 0);
178+
st.end();
179+
});
180+
181+
t.test('link properly using manual reference search', function (st) {
182+
/*
183+
'lib.sol': 'library L { function f() public returns (uint) { return 7; } }',
184+
'cont.sol': 'import "lib.sol"; contract x { function g() public { L.f(); } }'
185+
*/
186+
var bytecode = '608060405234801561001057600080fd5b5061011f806100206000396000f300608060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063e2179b8e146044575b600080fd5b348015604f57600080fd5b5060566058565b005b73__lib.sol:L_____________________________6326121ff06040518163ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040160206040518083038186803b15801560b757600080fd5b505af415801560ca573d6000803e3d6000fd5b505050506040513d602081101560df57600080fd5b8101908080519060200190929190505050505600a165627a7a72305820ea2f6353179c181d7162544d637b7fe2d9e8da9803a0e2d9eafc2188d1d59ee30029';
187+
bytecode = linker.linkBytecode(bytecode, { 'lib.sol:L': '0x123456' }, {});
188+
st.ok(bytecode.indexOf('_') < 0);
189+
st.end();
190+
});
169191
});

0 commit comments

Comments
 (0)