(t *testing.T)
| 9 | ) |
| 10 | |
| 11 | func TestEthSECP256K1Bytes(t *testing.T) { |
| 12 | // private key testing |
| 13 | privateKey, err := NewETHSECP256K1PrivateKey() |
| 14 | if err != nil { |
| 15 | t.Fatal(err) |
| 16 | } |
| 17 | privKeyBz := privateKey.Bytes() |
| 18 | privateKey2, err := BytesToSECP256K1Private(privKeyBz) |
| 19 | require.NoError(t, err) |
| 20 | if !privateKey.Equals(privateKey2) { |
| 21 | t.Fatalf("wanted %s, got %s", privateKey, privateKey2) |
| 22 | } |
| 23 | // public key testing |
| 24 | pubKey := privateKey.PublicKey() |
| 25 | pubKeyBz := pubKey.Bytes() |
| 26 | fmt.Println(len(pubKeyBz), hex.EncodeToString(pubKeyBz)) |
| 27 | pubKey2, err := BytesToEthSECP256K1Public(pubKeyBz) |
| 28 | require.NoError(t, err) |
| 29 | if !pubKey.Equals(pubKey2) { |
| 30 | t.Fatalf("wanted %s got %s", pubKey, pubKey2) |
| 31 | } |
| 32 | // address testing |
| 33 | address := pubKey.Address() |
| 34 | addressBz := address.Bytes() |
| 35 | address2 := NewAddressFromBytes(addressBz) |
| 36 | if !address.Equals(address2) { |
| 37 | t.Fatalf("wanted %s got %s", address, address2) |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | func TestEthSECP256K1SignAndVerify(t *testing.T) { |
| 42 | // create the private key |
nothing calls this directly
no test coverage detected