mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-13 23:43:47 +00:00
accounts/abi/bind: don't define link test case table as a package-private variable
This commit is contained in:
parent
7f301229bf
commit
6afe90dddd
1 changed files with 109 additions and 111 deletions
|
|
@ -205,124 +205,122 @@ func testLinkCase(tcInput linkTestCaseInput) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var linkTestCases = []linkTestCaseInput{
|
func TestContractLinking(t *testing.T) {
|
||||||
// test simple contract without any dependencies or overrides
|
for i, tc := range []linkTestCaseInput{
|
||||||
{
|
// test simple contract without any dependencies or overrides
|
||||||
map[rune][]rune{
|
{
|
||||||
'a': {}},
|
map[rune][]rune{
|
||||||
map[rune]struct{}{},
|
'a': {}},
|
||||||
map[rune]struct{}{
|
map[rune]struct{}{},
|
||||||
'a': {}},
|
map[rune]struct{}{
|
||||||
},
|
'a': {}},
|
||||||
// test deployment of a contract that depends on somes libraries.
|
|
||||||
{
|
|
||||||
map[rune][]rune{
|
|
||||||
'a': {'b', 'c', 'd', 'e'}},
|
|
||||||
map[rune]struct{}{},
|
|
||||||
map[rune]struct{}{
|
|
||||||
'a': {}, 'b': {}, 'c': {}, 'd': {}, 'e': {}},
|
|
||||||
},
|
|
||||||
// test deployment of a contract that depends on some libraries,
|
|
||||||
// one of which has its own library dependencies.
|
|
||||||
{
|
|
||||||
map[rune][]rune{
|
|
||||||
'a': {'b', 'c', 'd', 'e'},
|
|
||||||
'e': {'f', 'g', 'h', 'i'}},
|
|
||||||
map[rune]struct{}{},
|
|
||||||
map[rune]struct{}{
|
|
||||||
'a': {}, 'b': {}, 'c': {}, 'd': {}, 'e': {}, 'f': {}, 'g': {}, 'h': {}, 'i': {}},
|
|
||||||
},
|
|
||||||
// test single contract only without deps
|
|
||||||
{
|
|
||||||
map[rune][]rune{
|
|
||||||
'a': {}},
|
|
||||||
map[rune]struct{}{},
|
|
||||||
map[rune]struct{}{
|
|
||||||
'a': {},
|
|
||||||
},
|
},
|
||||||
},
|
// test deployment of a contract that depends on somes libraries.
|
||||||
// test that libraries at different levels of the tree can share deps,
|
{
|
||||||
// and that these shared deps will only be deployed once.
|
map[rune][]rune{
|
||||||
{
|
'a': {'b', 'c', 'd', 'e'}},
|
||||||
map[rune][]rune{
|
map[rune]struct{}{},
|
||||||
'a': {'b', 'c', 'd', 'e'},
|
map[rune]struct{}{
|
||||||
'e': {'f', 'g', 'h', 'i', 'm'},
|
'a': {}, 'b': {}, 'c': {}, 'd': {}, 'e': {}},
|
||||||
'i': {'j', 'k', 'l', 'm'}},
|
|
||||||
map[rune]struct{}{},
|
|
||||||
map[rune]struct{}{
|
|
||||||
'a': {}, 'b': {}, 'c': {}, 'd': {}, 'e': {}, 'f': {}, 'g': {}, 'h': {}, 'i': {}, 'j': {}, 'k': {}, 'l': {}, 'm': {},
|
|
||||||
},
|
},
|
||||||
},
|
// test deployment of a contract that depends on some libraries,
|
||||||
// test two contracts can be deployed which don't share deps
|
// one of which has its own library dependencies.
|
||||||
linkTestCaseInput{
|
{
|
||||||
map[rune][]rune{
|
map[rune][]rune{
|
||||||
'a': {'b', 'c', 'd', 'e'},
|
'a': {'b', 'c', 'd', 'e'},
|
||||||
'f': {'g', 'h', 'i', 'j'}},
|
'e': {'f', 'g', 'h', 'i'}},
|
||||||
map[rune]struct{}{},
|
map[rune]struct{}{},
|
||||||
map[rune]struct{}{
|
map[rune]struct{}{
|
||||||
'a': {}, 'b': {}, 'c': {}, 'd': {}, 'e': {}, 'f': {}, 'g': {}, 'h': {}, 'i': {}, 'j': {},
|
'a': {}, 'b': {}, 'c': {}, 'd': {}, 'e': {}, 'f': {}, 'g': {}, 'h': {}, 'i': {}},
|
||||||
},
|
},
|
||||||
},
|
// test single contract only without deps
|
||||||
// test two contracts can be deployed which share deps
|
{
|
||||||
linkTestCaseInput{
|
map[rune][]rune{
|
||||||
map[rune][]rune{
|
'a': {}},
|
||||||
|
map[rune]struct{}{},
|
||||||
|
map[rune]struct{}{
|
||||||
|
'a': {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
// test that libraries at different levels of the tree can share deps,
|
||||||
|
// and that these shared deps will only be deployed once.
|
||||||
|
{
|
||||||
|
map[rune][]rune{
|
||||||
|
'a': {'b', 'c', 'd', 'e'},
|
||||||
|
'e': {'f', 'g', 'h', 'i', 'm'},
|
||||||
|
'i': {'j', 'k', 'l', 'm'}},
|
||||||
|
map[rune]struct{}{},
|
||||||
|
map[rune]struct{}{
|
||||||
|
'a': {}, 'b': {}, 'c': {}, 'd': {}, 'e': {}, 'f': {}, 'g': {}, 'h': {}, 'i': {}, 'j': {}, 'k': {}, 'l': {}, 'm': {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
// test two contracts can be deployed which don't share deps
|
||||||
|
linkTestCaseInput{
|
||||||
|
map[rune][]rune{
|
||||||
|
'a': {'b', 'c', 'd', 'e'},
|
||||||
|
'f': {'g', 'h', 'i', 'j'}},
|
||||||
|
map[rune]struct{}{},
|
||||||
|
map[rune]struct{}{
|
||||||
|
'a': {}, 'b': {}, 'c': {}, 'd': {}, 'e': {}, 'f': {}, 'g': {}, 'h': {}, 'i': {}, 'j': {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
// test two contracts can be deployed which share deps
|
||||||
|
linkTestCaseInput{
|
||||||
|
map[rune][]rune{
|
||||||
|
'a': {'b', 'c', 'd', 'e'},
|
||||||
|
'f': {'g', 'c', 'd', 'h'}},
|
||||||
|
map[rune]struct{}{},
|
||||||
|
map[rune]struct{}{
|
||||||
|
'a': {}, 'b': {}, 'c': {}, 'd': {}, 'e': {}, 'f': {}, 'g': {}, 'h': {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
// test one contract with overrides for all lib deps
|
||||||
|
linkTestCaseInput{
|
||||||
|
map[rune][]rune{
|
||||||
|
'a': {'b', 'c', 'd', 'e'}},
|
||||||
|
map[rune]struct{}{'b': {}, 'c': {}, 'd': {}, 'e': {}},
|
||||||
|
map[rune]struct{}{
|
||||||
|
'a': {}},
|
||||||
|
},
|
||||||
|
// test one contract with overrides for some lib deps
|
||||||
|
linkTestCaseInput{
|
||||||
|
map[rune][]rune{
|
||||||
|
'a': {'b', 'c'}},
|
||||||
|
map[rune]struct{}{'b': {}, 'c': {}},
|
||||||
|
map[rune]struct{}{
|
||||||
|
'a': {}},
|
||||||
|
},
|
||||||
|
// test deployment of a contract with overrides
|
||||||
|
linkTestCaseInput{
|
||||||
|
map[rune][]rune{
|
||||||
|
'a': {}},
|
||||||
|
map[rune]struct{}{'a': {}},
|
||||||
|
map[rune]struct{}{},
|
||||||
|
},
|
||||||
|
// two contracts ('a' and 'f') share some dependencies. contract 'a' is marked as an override. expect that any of
|
||||||
|
// its depdencies that aren't shared with 'f' are not deployed.
|
||||||
|
linkTestCaseInput{map[rune][]rune{
|
||||||
'a': {'b', 'c', 'd', 'e'},
|
'a': {'b', 'c', 'd', 'e'},
|
||||||
'f': {'g', 'c', 'd', 'h'}},
|
'f': {'g', 'c', 'd', 'h'}},
|
||||||
map[rune]struct{}{},
|
map[rune]struct{}{'a': {}},
|
||||||
map[rune]struct{}{
|
map[rune]struct{}{
|
||||||
'a': {}, 'b': {}, 'c': {}, 'd': {}, 'e': {}, 'f': {}, 'g': {}, 'h': {},
|
'f': {}, 'g': {}, 'c': {}, 'd': {}, 'h': {}},
|
||||||
},
|
},
|
||||||
},
|
// test nested libraries that share deps at different levels of the tree... with override.
|
||||||
// test one contract with overrides for all lib deps
|
// same condition as above test: no sub-dependencies of
|
||||||
linkTestCaseInput{
|
{
|
||||||
map[rune][]rune{
|
map[rune][]rune{
|
||||||
'a': {'b', 'c', 'd', 'e'}},
|
'a': {'b', 'c', 'd', 'e'},
|
||||||
map[rune]struct{}{'b': {}, 'c': {}, 'd': {}, 'e': {}},
|
'e': {'f', 'g', 'h', 'i', 'm'},
|
||||||
map[rune]struct{}{
|
'i': {'j', 'k', 'l', 'm'},
|
||||||
'a': {}},
|
'l': {'n', 'o', 'p'}},
|
||||||
},
|
map[rune]struct{}{
|
||||||
// test one contract with overrides for some lib deps
|
'i': {},
|
||||||
linkTestCaseInput{
|
},
|
||||||
map[rune][]rune{
|
map[rune]struct{}{
|
||||||
'a': {'b', 'c'}},
|
'a': {}, 'b': {}, 'c': {}, 'd': {}, 'e': {}, 'f': {}, 'g': {}, 'h': {}, 'm': {}},
|
||||||
map[rune]struct{}{'b': {}, 'c': {}},
|
|
||||||
map[rune]struct{}{
|
|
||||||
'a': {}},
|
|
||||||
},
|
|
||||||
// test deployment of a contract with overrides
|
|
||||||
linkTestCaseInput{
|
|
||||||
map[rune][]rune{
|
|
||||||
'a': {}},
|
|
||||||
map[rune]struct{}{'a': {}},
|
|
||||||
map[rune]struct{}{},
|
|
||||||
},
|
|
||||||
// two contracts ('a' and 'f') share some dependencies. contract 'a' is marked as an override. expect that any of
|
|
||||||
// its depdencies that aren't shared with 'f' are not deployed.
|
|
||||||
linkTestCaseInput{map[rune][]rune{
|
|
||||||
'a': {'b', 'c', 'd', 'e'},
|
|
||||||
'f': {'g', 'c', 'd', 'h'}},
|
|
||||||
map[rune]struct{}{'a': {}},
|
|
||||||
map[rune]struct{}{
|
|
||||||
'f': {}, 'g': {}, 'c': {}, 'd': {}, 'h': {}},
|
|
||||||
},
|
|
||||||
// test nested libraries that share deps at different levels of the tree... with override.
|
|
||||||
// same condition as above test: no sub-dependencies of
|
|
||||||
{
|
|
||||||
map[rune][]rune{
|
|
||||||
'a': {'b', 'c', 'd', 'e'},
|
|
||||||
'e': {'f', 'g', 'h', 'i', 'm'},
|
|
||||||
'i': {'j', 'k', 'l', 'm'},
|
|
||||||
'l': {'n', 'o', 'p'}},
|
|
||||||
map[rune]struct{}{
|
|
||||||
'i': {},
|
|
||||||
},
|
},
|
||||||
map[rune]struct{}{
|
} {
|
||||||
'a': {}, 'b': {}, 'c': {}, 'd': {}, 'e': {}, 'f': {}, 'g': {}, 'h': {}, 'm': {}},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestContractLinking(t *testing.T) {
|
|
||||||
for i, tc := range linkTestCases {
|
|
||||||
if err := testLinkCase(tc); err != nil {
|
if err := testLinkCase(tc); err != nil {
|
||||||
t.Fatalf("test case %d failed: %v", i, err)
|
t.Fatalf("test case %d failed: %v", i, err)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue