Skip to content

Commit 2dac8d7

Browse files
authored
Merge pull request #272 from ethereum/linking-bytecode
Use bytecode for the linker tests
2 parents bbe4275 + fa40c12 commit 2dac8d7

File tree

1 file changed

+15
-30
lines changed

1 file changed

+15
-30
lines changed

test/package.js

Lines changed: 15 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -556,71 +556,56 @@ tape('Linking', function (t) {
556556
}
557557

558558
t.test('link properly', function (st) {
559-
var input = {
559+
/*
560560
'lib.sol': 'library L { function f() public returns (uint) { return 7; } }',
561561
'cont.sol': 'import "lib.sol"; contract x { function g() public { L.f(); } }'
562-
};
563-
var output = solc.compile({sources: input});
564-
var bytecode = getBytecode(output, 'cont.sol', 'x');
565-
st.ok(bytecode);
566-
st.ok(bytecode.length > 0);
562+
*/
563+
var bytecode = '608060405234801561001057600080fd5b5061011f806100206000396000f300608060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063e2179b8e146044575b600080fd5b348015604f57600080fd5b5060566058565b005b73__lib.sol:L_____________________________6326121ff06040518163ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040160206040518083038186803b15801560b757600080fd5b505af415801560ca573d6000803e3d6000fd5b505050506040513d602081101560df57600080fd5b8101908080519060200190929190505050505600a165627a7a72305820ea2f6353179c181d7162544d637b7fe2d9e8da9803a0e2d9eafc2188d1d59ee30029';
567564
bytecode = linker.linkBytecode(bytecode, { 'lib.sol:L': '0x123456' });
568565
st.ok(bytecode.indexOf('_') < 0);
569566
st.end();
570567
});
571568

572569
t.test('link properly with two-level configuration (from standard JSON)', function (st) {
573-
var input = {
570+
/*
574571
'lib.sol': 'library L { function f() public returns (uint) { return 7; } }',
575572
'cont.sol': 'import "lib.sol"; contract x { function g() public { L.f(); } }'
576-
};
577-
var output = solc.compile({sources: input});
578-
var bytecode = getBytecode(output, 'cont.sol', 'x');
579-
st.ok(bytecode);
580-
st.ok(bytecode.length > 0);
573+
*/
574+
var bytecode = '608060405234801561001057600080fd5b5061011f806100206000396000f300608060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063e2179b8e146044575b600080fd5b348015604f57600080fd5b5060566058565b005b73__lib.sol:L_____________________________6326121ff06040518163ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040160206040518083038186803b15801560b757600080fd5b505af415801560ca573d6000803e3d6000fd5b505050506040513d602081101560df57600080fd5b8101908080519060200190929190505050505600a165627a7a72305820ea2f6353179c181d7162544d637b7fe2d9e8da9803a0e2d9eafc2188d1d59ee30029';
581575
bytecode = linker.linkBytecode(bytecode, { 'lib.sol': { 'L': '0x123456' } });
582576
st.ok(bytecode.indexOf('_') < 0);
583577
st.end();
584578
});
585579

586580
t.test('linker to fail with missing library', function (st) {
587-
var input = {
581+
/*
588582
'lib.sol': 'library L { function f() public returns (uint) { return 7; } }',
589583
'cont.sol': 'import "lib.sol"; contract x { function g() public { L.f(); } }'
590-
};
591-
var output = solc.compile({sources: input});
592-
var bytecode = getBytecode(output, 'cont.sol', 'x');
593-
st.ok(bytecode);
594-
st.ok(bytecode.length > 0);
584+
*/
585+
var bytecode = '608060405234801561001057600080fd5b5061011f806100206000396000f300608060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063e2179b8e146044575b600080fd5b348015604f57600080fd5b5060566058565b005b73__lib.sol:L_____________________________6326121ff06040518163ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040160206040518083038186803b15801560b757600080fd5b505af415801560ca573d6000803e3d6000fd5b505050506040513d602081101560df57600080fd5b8101908080519060200190929190505050505600a165627a7a72305820ea2f6353179c181d7162544d637b7fe2d9e8da9803a0e2d9eafc2188d1d59ee30029';
595586
bytecode = linker.linkBytecode(bytecode, { });
596587
st.ok(bytecode.indexOf('_') >= 0);
597588
st.end();
598589
});
599590

600591
t.test('linker to fail with invalid address', function (st) {
601-
var input = {
592+
/*
602593
'lib.sol': 'library L { function f() public returns (uint) { return 7; } }',
603594
'cont.sol': 'import "lib.sol"; contract x { function g() public { L.f(); } }'
604-
};
605-
var output = solc.compile({sources: input});
606-
var bytecode = getBytecode(output, 'cont.sol', 'x');
607-
st.ok(bytecode);
608-
st.ok(bytecode.length > 0);
595+
*/
596+
var bytecode = '608060405234801561001057600080fd5b5061011f806100206000396000f300608060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063e2179b8e146044575b600080fd5b348015604f57600080fd5b5060566058565b005b73__lib.sol:L_____________________________6326121ff06040518163ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040160206040518083038186803b15801560b757600080fd5b505af415801560ca573d6000803e3d6000fd5b505050506040513d602081101560df57600080fd5b8101908080519060200190929190505050505600a165627a7a72305820ea2f6353179c181d7162544d637b7fe2d9e8da9803a0e2d9eafc2188d1d59ee30029';
609597
st.throws(function () {
610598
linker.linkBytecode(bytecode, { 'lib.sol:L': '' });
611599
});
612600
st.end();
613601
});
614602

615603
t.test('linker properly with truncated library name', function (st) {
616-
var input = {
604+
/*
617605
'lib.sol': 'library L1234567890123456789012345678901234567890 { function f() public returns (uint) { return 7; } }',
618606
'cont.sol': 'import "lib.sol"; contract x { function g() public { L1234567890123456789012345678901234567890.f(); } }'
619-
};
620-
var output = solc.compile({sources: input});
621-
var bytecode = getBytecode(output, 'cont.sol', 'x');
622-
st.ok(bytecode);
623-
st.ok(bytecode.length > 0);
607+
*/
608+
var bytecode = '608060405234801561001057600080fd5b5061011f806100206000396000f300608060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063e2179b8e146044575b600080fd5b348015604f57600080fd5b5060566058565b005b73__lib.sol:L123456789012345678901234567__6326121ff06040518163ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040160206040518083038186803b15801560b757600080fd5b505af415801560ca573d6000803e3d6000fd5b505050506040513d602081101560df57600080fd5b8101908080519060200190929190505050505600a165627a7a723058209f88ff686bd8ceb0fc08853dc1332d5ff81dbcf5af3a1e9aa366828091761f8c0029';
624609
bytecode = linker.linkBytecode(bytecode, { 'lib.sol:L1234567890123456789012345678901234567890': '0x123456' });
625610
st.ok(bytecode.indexOf('_') < 0);
626611
st.end();

0 commit comments

Comments
 (0)