MCPcopy Create free account
hub / github.com/CPChain/chain / TestGetPrivateStateRoot

Function TestGetPrivateStateRoot

core/private_database_test.go:34–74  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

32)
33
34func TestGetPrivateStateRoot(t *testing.T) {
35 db := database.NewMemDatabase()
36 blockRoot := common.BytesToHash([]byte{1, 2, 3, 4, 5, 6, 7, 8})
37 privateRoot := common.BytesToHash([]byte{1, 2, 3, 4, 5, 6, 7, 8})
38
39 WritePrivateStateRoot(db, blockRoot, privateRoot)
40
41 type args struct {
42 db database.Database
43 blockRoot common.Hash
44 }
45 tests := []struct {
46 name string
47 args args
48 want common.Hash
49 }{
50 {
51 name: "Positive Case: get private state root",
52 args: args{
53 db: db,
54 blockRoot: blockRoot,
55 },
56 want: privateRoot,
57 },
58 {
59 name: "Get private state root which does not exist ",
60 args: args{
61 db: db,
62 blockRoot: common.Hash{},
63 },
64 want: common.Hash{},
65 },
66 }
67 for _, tt := range tests {
68 t.Run(tt.name, func(t *testing.T) {
69 if got := GetPrivateStateRoot(tt.args.db, tt.args.blockRoot); !reflect.DeepEqual(got, tt.want) {
70 t.Errorf("GetPrivateStateRoot() = %v, want %v", got, tt.want)
71 }
72 })
73 }
74}
75
76func TestWritePrivateStateRoot(t *testing.T) {
77 db := database.NewMemDatabase()

Callers

nothing calls this directly

Calls 3

WritePrivateStateRootFunction · 0.85
GetPrivateStateRootFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected