github.com/cheng762/platon-go@v1.8.17-0.20190529111256-7deff2d7be26/contracts/ens/ens_test.go (about)

     1  // Copyright 2016 The go-ethereum Authors
     2  // This file is part of the go-ethereum library.
     3  //
     4  // The go-ethereum library is free software: you can redistribute it and/or modify
     5  // it under the terms of the GNU Lesser General Public License as published by
     6  // the Free Software Foundation, either version 3 of the License, or
     7  // (at your option) any later version.
     8  //
     9  // The go-ethereum library is distributed in the hope that it will be useful,
    10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    12  // GNU Lesser General Public License for more details.
    13  //
    14  // You should have received a copy of the GNU Lesser General Public License
    15  // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
    16  
    17  package ens
    18  
    19  import (
    20  	"testing"
    21  
    22  	"github.com/PlatONnetwork/PlatON-Go/crypto"
    23  )
    24  
    25  var (
    26  	key, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
    27  	name   = "my name on ENS"
    28  	hash   = crypto.Keccak256Hash([]byte("my content"))
    29  	addr   = crypto.PubkeyToAddress(key.PublicKey)
    30  )
    31  
    32  func TestENS(t *testing.T) {
    33  	/*ppos_storage.NewPPosTemp(ethdb.NewMemDatabase())
    34  	contractBackend := backends.NewSimulatedBackend(core.GenesisAlloc{addr: {Balance: big.NewInt(10000000000000000)}}, 10000000)
    35  	transactOpts := bind.NewKeyedTransactor(key)
    36  
    37  	ensAddr, ens, err := DeployENS(transactOpts, contractBackend)
    38  	if err != nil {
    39  		t.Fatalf("can't deploy root registry: %v", err)
    40  	}
    41  	contractBackend.Commit()
    42  
    43  	// Set ourself as the owner of the name.
    44  	if _, err := ens.Register(name); err != nil {
    45  		t.Fatalf("can't register: %v", err)
    46  	}
    47  	contractBackend.Commit()
    48  
    49  	// Deploy a resolver and make it responsible for the name.
    50  	resolverAddr, _, _, err := contract.DeployPublicResolver(transactOpts, contractBackend, ensAddr)
    51  	if err != nil {
    52  		t.Fatalf("can't deploy resolver: %v", err)
    53  	}
    54  	if _, err := ens.SetResolver(EnsNode(name), resolverAddr); err != nil {
    55  		t.Fatalf("can't set resolver: %v", err)
    56  	}
    57  	contractBackend.Commit()
    58  
    59  	// Set the content hash for the name.
    60  	if _, err = ens.SetContentHash(name, hash); err != nil {
    61  		t.Fatalf("can't set content hash: %v", err)
    62  	}
    63  	contractBackend.Commit()
    64  
    65  	// Try to resolve the name.
    66  	vhost, err := ens.Resolve(name)
    67  	if err != nil {
    68  		t.Fatalf("expected no error, got %v", err)
    69  	}
    70  	if vhost != hash {
    71  		t.Fatalf("resolve error, expected %v, got %v", hash.Hex(), vhost.Hex())
    72  	}*/
    73  }