diff options
Diffstat (limited to 'contracts/ens/ens_test.go')
-rw-r--r-- | contracts/ens/ens_test.go | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/contracts/ens/ens_test.go b/contracts/ens/ens_test.go index 5faa9b1ad..0016f47db 100644 --- a/contracts/ens/ens_test.go +++ b/contracts/ens/ens_test.go @@ -22,6 +22,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/accounts/abi/bind/backends" + "github.com/ethereum/go-ethereum/contracts/ens/contract" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/crypto" ) @@ -36,27 +37,36 @@ var ( func TestENS(t *testing.T) { contractBackend := backends.NewSimulatedBackend(core.GenesisAlloc{addr: {Balance: big.NewInt(1000000000)}}) transactOpts := bind.NewKeyedTransactor(key) - // Workaround for bug estimating gas in the call to Register - transactOpts.GasLimit = big.NewInt(1000000) - ens, err := DeployENS(transactOpts, contractBackend) + ensAddr, ens, err := DeployENS(transactOpts, contractBackend) if err != nil { - t.Fatalf("expected no error, got %v", err) + t.Fatalf("can't deploy root registry: %v", err) } contractBackend.Commit() - _, err = ens.Register(name) - if err != nil { - t.Fatalf("expected no error, got %v", err) + // Set ourself as the owner of the name. + if _, err := ens.Register(name); err != nil { + t.Fatalf("can't register: %v", err) } contractBackend.Commit() - _, err = ens.SetContentHash(name, hash) + // Deploy a resolver and make it responsible for the name. + resolverAddr, _, _, err := contract.DeployPublicResolver(transactOpts, contractBackend, ensAddr) if err != nil { - t.Fatalf("expected no error, got %v", err) + t.Fatalf("can't deploy resolver: %v", err) + } + if _, err := ens.SetResolver(ensNode(name), resolverAddr); err != nil { + t.Fatalf("can't set resolver: %v", err) + } + contractBackend.Commit() + + // Set the content hash for the name. + if _, err = ens.SetContentHash(name, hash); err != nil { + t.Fatalf("can't set content hash: %v", err) } contractBackend.Commit() + // Try to resolve the name. vhost, err := ens.Resolve(name) if err != nil { t.Fatalf("expected no error, got %v", err) |