(t *testing.T)
| 64 | } |
| 65 | |
| 66 | func TestKeystoreDeleteKeyWithOpts(t *testing.T) { |
| 67 | password := "password" |
| 68 | // pre-create a new private key |
| 69 | private, err := NewBLS12381PrivateKey() |
| 70 | require.NoError(t, err) |
| 71 | // get the address |
| 72 | address := private.PublicKey().Address().Bytes() |
| 73 | // create a new in-memory keystore |
| 74 | ks := NewKeystoreInMemory() |
| 75 | // execute the function call |
| 76 | gotAddress, err := ks.ImportRaw(private.Bytes(), password, ImportRawOpts{ |
| 77 | Nickname: "pablito", |
| 78 | }) |
| 79 | require.NoError(t, err) |
| 80 | // validate got address vs expected |
| 81 | require.Equal(t, hex.EncodeToString(address), gotAddress) |
| 82 | // delete the key |
| 83 | ks.DeleteKey(DeleteOpts{ |
| 84 | Address: address, |
| 85 | }) |
| 86 | // check the key was imported with address |
| 87 | _, err = ks.GetKey(address, password) |
| 88 | require.ErrorContains(t, err, "key not found") |
| 89 | // check the key was imported with nickname |
| 90 | _, err = ks.GetKeyGroup(password, GetKeyGroupOpts{ |
| 91 | Nickname: "pablito", |
| 92 | }) |
| 93 | require.ErrorContains(t, err, "key not found") |
| 94 | |
| 95 | // execute the function call |
| 96 | gotAddress, err = ks.ImportRaw(private.Bytes(), password, ImportRawOpts{ |
| 97 | Nickname: "pablito", |
| 98 | }) |
| 99 | require.NoError(t, err) |
| 100 | // validate got address vs expected |
| 101 | require.Equal(t, hex.EncodeToString(address), gotAddress) |
| 102 | // delete the key |
| 103 | ks.DeleteKey(DeleteOpts{ |
| 104 | Nickname: "pablito", |
| 105 | }) |
| 106 | // check the key was imported with address |
| 107 | _, err = ks.GetKey(address, password) |
| 108 | require.ErrorContains(t, err, "key not found") |
| 109 | // check the key was imported with nickname |
| 110 | _, err = ks.GetKeyGroup(password, GetKeyGroupOpts{ |
| 111 | Nickname: "pablito", |
| 112 | }) |
| 113 | require.ErrorContains(t, err, "key not found") |
| 114 | } |
nothing calls this directly
no test coverage detected