(t *testing.T)
| 291 | } |
| 292 | |
| 293 | func TestTransactionResultJSON(t *testing.T) { |
| 294 | // pre-define a test message |
| 295 | sig := &Signature{ |
| 296 | PublicKey: newTestPublicKeyBytes(t), |
| 297 | Signature: newTestPublicKeyBytes(t), |
| 298 | } |
| 299 | // pre-define an any for testing |
| 300 | a, e := NewAny(sig) |
| 301 | require.NoError(t, e) |
| 302 | // pre-define a transaction |
| 303 | expected := &TxResult{ |
| 304 | Sender: newTestAddressBytes(t), |
| 305 | Recipient: newTestAddressBytes(t), |
| 306 | MessageType: testMessageName, |
| 307 | Height: 1, |
| 308 | Index: 2, |
| 309 | Transaction: &Transaction{ |
| 310 | MessageType: testMessageName, |
| 311 | Msg: a, |
| 312 | Signature: sig, |
| 313 | Time: uint64(time.Now().UnixMicro()), |
| 314 | Fee: 1, |
| 315 | Memo: "memo", |
| 316 | }, |
| 317 | TxHash: crypto.HashString([]byte("hash")), |
| 318 | } |
| 319 | // convert structure to json bytes |
| 320 | gotBytes, err := json.Marshal(expected) |
| 321 | require.NoError(t, err) |
| 322 | // convert bytes to structure |
| 323 | got := new(TxResult) |
| 324 | // unmarshal into bytes |
| 325 | require.NoError(t, json.Unmarshal(gotBytes, got)) |
| 326 | // hardcode time as we lose precision upon conversion |
| 327 | got.Transaction.Time = expected.Transaction.Time |
| 328 | // compare got vs expected |
| 329 | require.EqualExportedValues(t, expected, got) |
| 330 | } |
| 331 | |
| 332 | func TestSignatureJSON(t *testing.T) { |
| 333 | // pre-define a signature |
nothing calls this directly
no test coverage detected