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

Function startTestService

client/helper_test.go:95–192  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

93}
94
95func startTestService() (stopTestService func(), tempDir string, err error) {
96 var server *rpc.Server
97 var cleanup func()
98 if cleanup, tempDir, server, err = initNode(); err != nil {
99 return
100 }
101
102 var rootDir string
103 if rootDir, err = ioutil.TempDir("", "dbms_test_"); err != nil {
104 return
105 }
106
107 cfg := &worker.DBMSConfig{
108 RootDir: rootDir,
109 Server: server,
110 MaxReqTimeGap: worker.DefaultMaxReqTimeGap,
111 }
112
113 var dbms *worker.DBMS
114 if dbms, err = worker.NewDBMS(cfg); err != nil {
115 return
116 }
117
118 stopTestService = func() {
119 if dbms != nil {
120 dbms.Shutdown()
121 }
122
123 cleanup()
124
125 // cleanup session pool
126 rpc.GetSessionPoolInstance().Close()
127 }
128
129 // init
130 if err = dbms.Init(); err != nil {
131 return
132 }
133
134 // add database
135 var req *types.UpdateService
136 var res types.UpdateServiceResponse
137 var peers *proto.Peers
138 var block *types.Block
139
140 dbID := proto.DatabaseID("db")
141
142 // create sqlchain block
143 block, err = types.CreateRandomBlock(rootHash, true)
144
145 // get database peers
146 if peers, err = genPeers(1); err != nil {
147 return
148 }
149
150 // build create database request
151 req = new(types.UpdateService)
152 req.Header.Op = types.CreateDB

Callers 12

TestConnFunction · 0.85
TestTransactionFunction · 0.85
TestStmtFunction · 0.85
TestInitFunction · 0.85
TestDefaultInitFunction · 0.85
TestCreateFunction · 0.85
TestDropFunction · 0.85
TestGetTokenBalanceFunction · 0.85
TestWaitDBCreationFunction · 0.85
TestTransferTokenFunction · 0.85
TestUpdatePermissionFunction · 0.85
TestRunPeerListUpdaterFunction · 0.85

Calls 15

ShutdownMethod · 0.95
InitMethod · 0.95
SignMethod · 0.95
PubKeyMethod · 0.95
UpdatePermissionMethod · 0.95
NewDBMSFunction · 0.92
DatabaseIDTypeAlias · 0.92
CreateRandomBlockFunction · 0.92
GetLocalPublicKeyFunction · 0.92
GetLocalPrivateKeyFunction · 0.92
PubKeyHashFunction · 0.92
UserPermissionFromRoleFunction · 0.92

Tested by

no test coverage detected