(t *testing.T)
| 225 | } |
| 226 | |
| 227 | func TestSign(t *testing.T) { |
| 228 | // pre-define a private key |
| 229 | pk, err := crypto.NewBLS12381PrivateKey() |
| 230 | require.NoError(t, err) |
| 231 | // pre-define a test message |
| 232 | sig := &Signature{ |
| 233 | PublicKey: newTestPublicKeyBytes(t), |
| 234 | Signature: newTestPublicKeyBytes(t), |
| 235 | } |
| 236 | // pre-define an any for testing |
| 237 | a, e := NewAny(sig) |
| 238 | require.NoError(t, e) |
| 239 | // pre-define a transaction |
| 240 | tx := &Transaction{ |
| 241 | MessageType: testMessageName, |
| 242 | Msg: a, |
| 243 | Signature: sig, |
| 244 | Time: uint64(time.Now().UnixMicro()), |
| 245 | Fee: 1, |
| 246 | Memo: "memo", |
| 247 | } |
| 248 | // get sign bytes |
| 249 | bz, err := tx.GetSignBytes() |
| 250 | require.NoError(t, err) |
| 251 | // calculate expected |
| 252 | expected := &Signature{ |
| 253 | PublicKey: pk.PublicKey().Bytes(), |
| 254 | Signature: pk.Sign(bz), |
| 255 | } |
| 256 | // execute function call |
| 257 | require.NoError(t, tx.Sign(pk)) |
| 258 | // compare got vs expected |
| 259 | require.EqualExportedValues(t, expected, tx.Signature) |
| 260 | } |
| 261 | |
| 262 | func TestTransactionJSON(t *testing.T) { |
| 263 | // pre-define a test message |
nothing calls this directly
no test coverage detected