MCPcopy Create free account
hub / github.com/CovenantSQL/CovenantSQL / TestComputeMetrics

Function TestComputeMetrics

cmd/cql-minerd/various_metric_test.go:281–384  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

279}
280
281func TestComputeMetrics(t *testing.T) {
282 Convey("compute metrics", t, func() {
283 priv, _, err := asymmetric.GenSecp256k1KeyPair()
284 So(err, ShouldBeNil)
285
286 var n proto.NodeID
287 var a proto.AccountAddress
288
289 r := &types.Request{
290 Header: types.SignedRequestHeader{
291 RequestHeader: types.RequestHeader{
292 QueryType: types.WriteQuery,
293 NodeID: n.ToRawNodeID().ToNodeID(),
294 DatabaseID: a.DatabaseID(),
295 ConnectionID: 0,
296 SeqNo: 1,
297 Timestamp: time.Now().UTC(),
298 BatchCount: 1,
299 },
300 },
301 Payload: types.RequestPayload{
302 Queries: []types.Query{
303 {
304 Pattern: "INSERT INTO insert_table0 ( k, v1 ) VALUES(?, ?)",
305 Args: []types.NamedArg{
306 {
307 Value: 1,
308 },
309 {
310 Value: 2,
311 },
312 },
313 },
314 },
315 },
316 }
317
318 err = r.Sign(priv)
319 So(err, ShouldBeNil)
320
321 buf, err := utils.EncodeMsgPack(r)
322 So(err, ShouldBeNil)
323
324 t.Logf("RequestSize: %v", len(buf.Bytes()))
325
326 l := &kt.Log{
327 LogHeader: kt.LogHeader{
328 Index: 1,
329 Version: 1,
330 Type: kt.LogPrepare,
331 Producer: n.ToRawNodeID().ToNodeID(),
332 },
333 Data: buf.Bytes(),
334 }
335
336 buf2, err := utils.EncodeMsgPack(l)
337 So(err, ShouldBeNil)
338

Callers

nothing calls this directly

Calls 10

ToRawNodeIDMethod · 0.95
DatabaseIDMethod · 0.95
SignMethod · 0.95
GenSecp256k1KeyPairFunction · 0.92
EncodeMsgPackFunction · 0.92
PubKeyHashFunction · 0.92
ToNodeIDMethod · 0.80
PubKeyMethod · 0.80
HashMethod · 0.65
BytesMethod · 0.45

Tested by

no test coverage detected