remove debug prints. fix contract linking test condition

This commit is contained in:
Jared Wasinger 2024-12-10 16:07:05 +07:00 committed by Felix Lange
parent c293caade9
commit e7e1426d89
2 changed files with 8 additions and 11 deletions

View File

@ -7,7 +7,6 @@ import (
"github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto"
"golang.org/x/exp/rand" "golang.org/x/exp/rand"
"runtime/debug"
"testing" "testing"
) )
@ -107,14 +106,16 @@ func testLinkCase(t *testing.T, tcInput linkTestCaseInput) {
contractAddr := crypto.CreateAddress(testAddr, testAddrNonce) contractAddr := crypto.CreateAddress(testAddr, testAddrNonce)
testAddrNonce++ testAddrNonce++
if len(deployer) >= 20 {
// assert that this contract only references libs that are known to be deployed or in the override set // assert that this contract only references libs that are known to be deployed or in the override set
for i := 0; i < len(deployer)/20; i += 20 { for i := 0; i < len(deployer); i += 20 {
var dep common.Address var dep common.Address
dep.SetBytes(deployer[i : i+20]) dep.SetBytes(deployer[i : i+20])
if _, ok := overridesAddrs[dep]; !ok { if _, ok := overridesAddrs[dep]; !ok {
t.Fatalf("reference to dependent contract that has not yet been deployed: %x\n", dep) t.Fatalf("reference to dependent contract that has not yet been deployed: %x\n", dep)
} }
} }
}
overridesAddrs[contractAddr] = struct{}{} overridesAddrs[contractAddr] = struct{}{}
// we don't care about the txs themselves for the sake of the linking tests. so we can return nil for them in the mock deployer // we don't care about the txs themselves for the sake of the linking tests. so we can return nil for them in the mock deployer
return contractAddr, nil, nil return contractAddr, nil, nil
@ -145,7 +146,6 @@ func testLinkCase(t *testing.T, tcInput linkTestCaseInput) {
} }
if len(res.Addrs) != len(tcInput.expectDeployed) { if len(res.Addrs) != len(tcInput.expectDeployed) {
debug.PrintStack()
t.Fatalf("got %d deployed contracts. expected %d.\n", len(res.Addrs), len(tcInput.expectDeployed)) t.Fatalf("got %d deployed contracts. expected %d.\n", len(res.Addrs), len(tcInput.expectDeployed))
} }
for contract, _ := range tcInput.expectDeployed { for contract, _ := range tcInput.expectDeployed {
@ -166,7 +166,6 @@ func TestContractLinking(t *testing.T) {
}, },
}) })
fmt.Println("2")
testLinkCase(t, linkTestCaseInput{ testLinkCase(t, linkTestCaseInput{
map[rune][]rune{ map[rune][]rune{
'a': {'b', 'c', 'd', 'e'}, 'a': {'b', 'c', 'd', 'e'},

View File

@ -208,8 +208,6 @@ func LinkAndDeploy(deployParams DeploymentParams, deploy func(input, deployer []
deps := treeBuilder.BuildDepTrees() deps := treeBuilder.BuildDepTrees()
for _, tr := range deps { for _, tr := range deps {
// TODO: instantiate deployer with its tree?
deployer := treeDeployer{ deployer := treeDeployer{
deploy: deploy, deploy: deploy,
deployedAddrs: make(map[string]common.Address), deployedAddrs: make(map[string]common.Address),