MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / TestMarshalHashAccountStable2

Function TestMarshalHashAccountStable2

types/marshalhash_test.go:47–73  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

45}
46
47func TestMarshalHashAccountStable2(t *testing.T) {
48 v1 := Account{
49 Address: proto.AccountAddress{0x10},
50 TokenBalance: [SupportTokenNumber]uint64{10, 10},
51 Rating: 1110,
52 NextNonce: 1,
53 }
54 enc, err := utils.EncodeMsgPack(&v1)
55 if err != nil {
56 t.Fatalf("error occurred: %v", err)
57 }
58 v2 := Account{}
59 if err = utils.DecodeMsgPack(enc.Bytes(), &v2); err != nil {
60 t.Fatalf("error occurred: %v", err)
61 }
62 bts1, err := v1.MarshalHash()
63 if err != nil {
64 t.Fatal(err)
65 }
66 bts2, err := v2.MarshalHash()
67 if err != nil {
68 t.Fatal(err)
69 }
70 if !bytes.Equal(bts1, bts2) {
71 t.Fatal("hash not stable")
72 }
73}

Callers

nothing calls this directly

Calls 6

MarshalHashMethod · 0.95
EncodeMsgPackFunction · 0.92
DecodeMsgPackFunction · 0.92
FatalfMethod · 0.80
FatalMethod · 0.80
BytesMethod · 0.45

Tested by

no test coverage detected