diff options
author | Javier Peletier <jpeletier@users.noreply.github.com> | 2018-09-29 04:46:41 +0800 |
---|---|---|
committer | Felix Lange <fjl@users.noreply.github.com> | 2018-09-29 04:46:41 +0800 |
commit | f1b9a3e2f415f6fc43519fdfc5b28ac2afcdada0 (patch) | |
tree | 8a69bda14344da2d8829b74992fa6de5cb213890 /contracts/ens/ens_test.go | |
parent | 79ca6c7a657f5f6660fb136707edb07951bb3309 (diff) | |
download | go-tangerine-f1b9a3e2f415f6fc43519fdfc5b28ac2afcdada0.tar go-tangerine-f1b9a3e2f415f6fc43519fdfc5b28ac2afcdada0.tar.gz go-tangerine-f1b9a3e2f415f6fc43519fdfc5b28ac2afcdada0.tar.bz2 go-tangerine-f1b9a3e2f415f6fc43519fdfc5b28ac2afcdada0.tar.lz go-tangerine-f1b9a3e2f415f6fc43519fdfc5b28ac2afcdada0.tar.xz go-tangerine-f1b9a3e2f415f6fc43519fdfc5b28ac2afcdada0.tar.zst go-tangerine-f1b9a3e2f415f6fc43519fdfc5b28ac2afcdada0.zip |
contracts/ens: expose Add and SetAddr in ENS (#17661)
I am planning to use this to resolve names to user addresses for Swarm/MRU feeds.
Diffstat (limited to 'contracts/ens/ens_test.go')
-rw-r--r-- | contracts/ens/ens_test.go | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/contracts/ens/ens_test.go b/contracts/ens/ens_test.go index 411b04197..cd64fbf15 100644 --- a/contracts/ens/ens_test.go +++ b/contracts/ens/ens_test.go @@ -22,16 +22,18 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/accounts/abi/bind/backends" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/contracts/ens/contract" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/crypto" ) var ( - key, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") - name = "my name on ENS" - hash = crypto.Keccak256Hash([]byte("my content")) - addr = crypto.PubkeyToAddress(key.PublicKey) + key, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") + name = "my name on ENS" + hash = crypto.Keccak256Hash([]byte("my content")) + addr = crypto.PubkeyToAddress(key.PublicKey) + testAddr = common.HexToAddress("0x1234123412341234123412341234123412341234") ) func TestENS(t *testing.T) { @@ -74,4 +76,19 @@ func TestENS(t *testing.T) { if vhost != hash { t.Fatalf("resolve error, expected %v, got %v", hash.Hex(), vhost.Hex()) } + + // set the address for the name + if _, err = ens.SetAddr(name, testAddr); err != nil { + t.Fatalf("can't set address: %v", err) + } + contractBackend.Commit() + + // Try to resolve the name to an address + recoveredAddr, err := ens.Addr(name) + if err != nil { + t.Fatalf("expected no error, got %v", err) + } + if vhost != hash { + t.Fatalf("resolve error, expected %v, got %v", testAddr.Hex(), recoveredAddr.Hex()) + } } |