MCPcopy
hub / github.com/canopy-network/canopy / TestCheckpointHash

Function TestCheckpointHash

lib/certificate_test.go:393–426  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

391}
392
393func TestCheckpointHash(t *testing.T) {
394 // pre-define a certificate result object
395 result := &CertificateResult{
396 RewardRecipients: &RewardRecipients{
397 PaymentPercents: []*PaymentPercents{{
398 Address: newTestAddressBytes(t),
399 Percent: 100,
400 }},
401 },
402 Orders: &Orders{
403 LockOrders: []*LockOrder{
404 {
405 OrderId: newTestOrderId(t, 0),
406 BuyerReceiveAddress: newTestAddressBytes(t),
407 BuyerChainDeadline: 0,
408 },
409 },
410 ResetOrders: [][]byte{newTestOrderId(t, 0)},
411 CloseOrders: [][]byte{newTestOrderId(t, 1)},
412 },
413 Checkpoint: &Checkpoint{
414 Height: 1,
415 BlockHash: []byte("hash"),
416 },
417 }
418 // calculate expected
419 bz, err := Marshal(result)
420 require.NoError(t, err)
421 expected := crypto.Hash(bz)
422 // execute function call
423 got := result.Hash()
424 // compare got vs expected
425 require.Equal(t, expected, got)
426}
427
428func TestCheckpointJSONHexEncoding(t *testing.T) {
429 original := &Checkpoint{

Callers

nothing calls this directly

Calls 6

HashMethod · 0.95
HashFunction · 0.92
EqualMethod · 0.80
newTestAddressBytesFunction · 0.70
newTestOrderIdFunction · 0.70
MarshalFunction · 0.70

Tested by

no test coverage detected