ethclient, internal/ethapi: add support for EIP-695 (eth_chainId) (#19694)

EIP-695 was written in 2017. Parity and Infura have support for this
method and we should, too.
This commit is contained in:
Felix Lange
2019-06-11 13:12:33 +02:00
committed by Péter Szilágyi
parent c420dcb39c
commit 2b54666018
3 changed files with 31 additions and 0 deletions

View File

@ -319,3 +319,19 @@ func TestTransactionInBlockInterrupted(t *testing.T) {
t.Fatal("error should not be nil")
}
}
func TestChainID(t *testing.T) {
backend, _ := newTestBackend(t)
client, _ := backend.Attach()
defer backend.Stop()
defer client.Close()
ec := NewClient(client)
id, err := ec.ChainID(context.Background())
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
if id == nil || id.Cmp(params.AllEthashProtocolChanges.ChainID) != 0 {
t.Fatalf("ChainID returned wrong number: %+v", id)
}
}