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

Function TestDBMS

worker/dbms_test.go:38–579  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

36)
37
38func TestDBMS(t *testing.T) {
39 Convey("test dbms", t, func() {
40 var err error
41 var server *rpc.Server
42 var cleanup func()
43 cleanup, server, err = initNode()
44 So(err, ShouldBeNil)
45
46 var (
47 privateKey *asymmetric.PrivateKey
48 publicKey *asymmetric.PublicKey
49 )
50 privateKey, err = kms.GetLocalPrivateKey()
51 So(err, ShouldBeNil)
52 publicKey = privateKey.PubKey()
53
54 var rootDir string
55 rootDir, err = ioutil.TempDir("", "dbms_test_")
56 So(err, ShouldBeNil)
57
58 cfg := &DBMSConfig{
59 RootDir: rootDir,
60 Server: server,
61 MaxReqTimeGap: time.Second * 5,
62 }
63
64 var dbms *DBMS
65 dbms, err = NewDBMS(cfg)
66 So(err, ShouldBeNil)
67
68 // init
69 err = dbms.Init()
70 So(err, ShouldBeNil)
71 dbms.busService.Stop()
72
73 // add database
74 var req *types.UpdateService
75 var res types.UpdateServiceResponse
76 var peers *proto.Peers
77 var block *types.Block
78 var nodeID proto.NodeID
79
80 nodeID, err = kms.GetLocalNodeID()
81
82 dbAddr := proto.AccountAddress(hash.HashH([]byte{'d', 'b'}))
83 dbID := dbAddr.DatabaseID()
84 dbAddr2 := proto.AccountAddress(hash.HashH([]byte{'a', 'b'}))
85 dbID2 := dbAddr2.DatabaseID()
86 userAddr, err := crypto.PubKeyHash(publicKey)
87 So(err, ShouldBeNil)
88
89 // create sqlchain block
90 block, err = types.CreateRandomBlock(rootHash, true)
91 So(err, ShouldBeNil)
92
93 // get peers
94 peers, err = getPeers(1)
95 So(err, ShouldBeNil)

Callers

nothing calls this directly

Calls 15

InitMethod · 0.95
SignMethod · 0.95
UpdatePermissionMethod · 0.95
observerFetchBlockMethod · 0.95
ShutdownMethod · 0.95
GetLocalPrivateKeyFunction · 0.92
GetLocalNodeIDFunction · 0.92
AccountAddressTypeAlias · 0.92
HashHFunction · 0.92
PubKeyHashFunction · 0.92
CreateRandomBlockFunction · 0.92
UserPermissionFromRoleFunction · 0.92

Tested by

no test coverage detected