-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathblock_test.go
More file actions
103 lines (90 loc) · 3.59 KB
/
Copy pathblock_test.go
File metadata and controls
103 lines (90 loc) · 3.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// SPDX-License-Identifier: Apache-2.0
//
// Copyright © 2022 The Cardano Community Authors
package koios_test
// func TestBlocks(t *testing.T) {
// client, err := getLiveClient()
// if testIsLocal(t, err) {
// return
// }
// blocksTest(t, client)
// }
// func blocksTest(t TestingT, client *koios.Client) {
// opts := client.NewRequestOptions()
// opts.SetPageSize(10)
// res, err := client.GetBlocks(context.Background(), opts)
// if !assert.NoError(t, err) {
// return
// }
// assertEqual(t, 10, len(res.Data), "total blocks returned")
// assertNotEmpty(t, res.Data[0].Hash, "hash")
// assertGreater(t, res.Data[0].EpochNo, koios.EpochNo(0), "epoch_no")
// assertGreater(t, res.Data[0].AbsSlot, koios.Slot(0), "abs_slot")
// assertGreater(t, res.Data[0].EpochSlot, koios.Slot(0), "epoch_slot")
// assertGreater(t, res.Data[0].Height, 0, "block_height")
// assertGreater(t, res.Data[0].Size, 0, "block_size")
// assertTimeNotZero(t, res.Data[0].Time, "block_time")
// if res.Data[0].TxCount == 0 {
// githubActionWarning("/blocks", fmt.Sprintf("block(%s) tx count is 0", res.Data[0].Hash))
// }
// assertNotEmpty(t, res.Data[0].VrfKey, "vrf_key")
// assertNotEmpty(t, res.Data[0].Pool, "pool")
// // assertGreater(t, res.Data[0].OpCertCounter, 0, "op_cert_counter")
// assertGreater(t, res.Data[0].ProtoMajor, 0, "proto_major")
// // assertGreater(t, res.Data[0].ProtoMinor, 0, "proto_minor")
// }
// func TestBlockInfo(t *testing.T) {
// client, err := getLiveClient()
// if testIsLocal(t, err) {
// return
// }
// blockInfoTest(t, networkBlockHash(), client)
// }
// func blockInfoTest(t TestingT, hash koios.BlockHash, client *koios.Client) {
// res, err := client.GetBlockInfo(context.Background(), hash, nil)
// if !assert.NoError(t, err) {
// return
// }
// assertNotEmpty(t, res.Data.Hash, "hash")
// assertGreater(t, res.Data.EpochNo, koios.EpochNo(0), "epoch_no")
// assertGreater(t, res.Data.AbsSlot, koios.Slot(0), "abs_slot")
// assertGreater(t, res.Data.EpochSlot, koios.Slot(0), "epoch_slot")
// assertGreater(t, res.Data.Height, 0, "block_height")
// assertGreater(t, res.Data.Size, 0, "block_size")
// assertTimeNotZero(t, res.Data.Time, "block_time")
// if res.Data.TxCount == 0 {
// githubActionWarning("/block_info", fmt.Sprintf("block(%s) tx count is 0", res.Data.Hash))
// } else {
// assertIsPositive(t, res.Data.TotalOutput, "total_output")
// assertIsPositive(t, res.Data.TotalFees, "total_fees")
// }
// assertNotEmpty(t, res.Data.VrfKey, "vrf_key")
// assertNotEmpty(t, res.Data.OpCert, "op_cert")
// // assertGreater(t, res.Data.OpCertCounter, 0, "op_cert_counter")
// assertNotEmpty(t, res.Data.Pool, "pool")
// assertGreater(t, res.Data.ProtoMajor, 0, "proto_major")
// // assertGreater(t, res.Data.ProtoMinor, 0, "proto_minor")
// assertGreater(t, res.Data.Confirmations, 0, "num_confirmations")
// assertNotEmpty(t, res.Data.ParentHash, "parent_hash")
// assertNotEmpty(t, res.Data.ChildHash, "child_hash")
// }
// func TestBlockTxs(t *testing.T) {
// client, err := getLiveClient()
// if testIsLocal(t, err) {
// return
// }
// blockTxsTest(t, networkBlockHash(), client)
// }
// func blockTxsTest(t TestingT, hash koios.BlockHash, client *koios.Client) {
// res, err := client.GetBlockTxs(context.Background(), hash, nil)
// if err != nil {
// if assert.ErrorIs(t, err, koios.ErrNoData) {
// githubActionWarning("BlockTxs", err.Error())
// return
// }
// assert.NoError(t, err)
// return
// }
// assertEqual(t, hash, res.Data.BlockHash, "req/res block hashes do not match")
// assertGreater(t, len(res.Data.TxHashes), 0, "tx_hashes")
// }