@blinklabs/dingo 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.dockerignore +5 -0
- package/.github/CODEOWNERS +5 -0
- package/.github/assets/dingo-ate-my-blockchain.png +0 -0
- package/.github/assets/dingo-illustration.png +0 -0
- package/.github/assets/dingo-logo-with-text-horizontal.png +0 -0
- package/.github/assets/dingo-logo-with-text.png +0 -0
- package/.github/dependabot.yml +19 -0
- package/.github/dingo-20241210.png +0 -0
- package/.github/dingo.md +56 -0
- package/.github/workflows/ci-docker.yml +36 -0
- package/.github/workflows/conventional-commits.yml +17 -0
- package/.github/workflows/go-test.yml +29 -0
- package/.github/workflows/golangci-lint.yml +23 -0
- package/.github/workflows/publish.yml +207 -0
- package/.golangci.yml +71 -0
- package/Dockerfile +25 -0
- package/LICENSE +201 -0
- package/Makefile +53 -0
- package/README.md +150 -0
- package/blockfetch.go +144 -0
- package/chain/chain.go +504 -0
- package/chain/chain_test.go +468 -0
- package/chain/errors.go +80 -0
- package/chain/event.go +33 -0
- package/chain/iter.go +64 -0
- package/chainsync/chainsync.go +97 -0
- package/chainsync.go +223 -0
- package/cmd/dingo/load.go +52 -0
- package/cmd/dingo/main.go +118 -0
- package/cmd/dingo/serve.go +49 -0
- package/config/cardano/node.go +192 -0
- package/config/cardano/node_test.go +85 -0
- package/config/cardano/preview/README.md +4 -0
- package/config/cardano/preview/alonzo-genesis.json +196 -0
- package/config/cardano/preview/byron-genesis.json +117 -0
- package/config/cardano/preview/config.json +114 -0
- package/config/cardano/preview/conway-genesis.json +297 -0
- package/config/cardano/preview/shelley-genesis.json +68 -0
- package/config.go +245 -0
- package/connmanager/connection_manager.go +105 -0
- package/connmanager/connection_manager_test.go +185 -0
- package/connmanager/event.go +37 -0
- package/connmanager/listener.go +140 -0
- package/connmanager/outbound.go +93 -0
- package/connmanager/socket.go +55 -0
- package/connmanager/unix.go +78 -0
- package/custom-p2p-topology.json +24 -0
- package/custom-p2p-topology.json.backup +24 -0
- package/custom-p2p-topology.json.mainnet +37 -0
- package/database/account.go +138 -0
- package/database/block.go +362 -0
- package/database/certs.go +53 -0
- package/database/commit_timestamp.go +77 -0
- package/database/database.go +118 -0
- package/database/database_test.go +62 -0
- package/database/drep.go +27 -0
- package/database/epoch.go +121 -0
- package/database/immutable/chunk.go +182 -0
- package/database/immutable/immutable.go +350 -0
- package/database/immutable/immutable_test.go +59 -0
- package/database/immutable/primary.go +106 -0
- package/database/immutable/secondary.go +103 -0
- package/database/immutable/testdata/08893.chunk +0 -0
- package/database/immutable/testdata/08893.primary +0 -0
- package/database/immutable/testdata/08893.secondary +0 -0
- package/database/immutable/testdata/08894.chunk +0 -0
- package/database/immutable/testdata/08894.primary +0 -0
- package/database/immutable/testdata/08894.secondary +0 -0
- package/database/immutable/testdata/README.md +4 -0
- package/database/plugin/blob/badger/commit_timestamp.go +50 -0
- package/database/plugin/blob/badger/database.go +152 -0
- package/database/plugin/blob/badger/logger.go +63 -0
- package/database/plugin/blob/badger/metrics.go +98 -0
- package/database/plugin/blob/blob.go +19 -0
- package/database/plugin/blob/store.go +40 -0
- package/database/plugin/log.go +27 -0
- package/database/plugin/metadata/metadata.go +19 -0
- package/database/plugin/metadata/sqlite/account.go +224 -0
- package/database/plugin/metadata/sqlite/certs.go +58 -0
- package/database/plugin/metadata/sqlite/commit_timestamp.go +68 -0
- package/database/plugin/metadata/sqlite/database.go +218 -0
- package/database/plugin/metadata/sqlite/epoch.go +120 -0
- package/database/plugin/metadata/sqlite/models/account.go +81 -0
- package/database/plugin/metadata/sqlite/models/auth_committee_hot.go +26 -0
- package/database/plugin/metadata/sqlite/models/deregistration_drep.go +26 -0
- package/database/plugin/metadata/sqlite/models/drep.go +27 -0
- package/database/plugin/metadata/sqlite/models/epoch.go +31 -0
- package/database/plugin/metadata/sqlite/models/models.go +45 -0
- package/database/plugin/metadata/sqlite/models/pool.go +97 -0
- package/database/plugin/metadata/sqlite/models/pparam_update.go +27 -0
- package/database/plugin/metadata/sqlite/models/pparams.go +27 -0
- package/database/plugin/metadata/sqlite/models/registration_drep.go +28 -0
- package/database/plugin/metadata/sqlite/models/resign_committee_cold.go +27 -0
- package/database/plugin/metadata/sqlite/models/stake_registration_delegation.go +27 -0
- package/database/plugin/metadata/sqlite/models/stake_vote_delegation.go +27 -0
- package/database/plugin/metadata/sqlite/models/stake_vote_registration_delegation.go +27 -0
- package/database/plugin/metadata/sqlite/models/tip.go +26 -0
- package/database/plugin/metadata/sqlite/models/update_drep.go +27 -0
- package/database/plugin/metadata/sqlite/models/utxo.go +30 -0
- package/database/plugin/metadata/sqlite/models/vote_delegation.go +26 -0
- package/database/plugin/metadata/sqlite/models/vote_registration_delegation.go +26 -0
- package/database/plugin/metadata/sqlite/pool.go +240 -0
- package/database/plugin/metadata/sqlite/pparams.go +110 -0
- package/database/plugin/metadata/sqlite/tip.go +83 -0
- package/database/plugin/metadata/sqlite/utxo.go +292 -0
- package/database/plugin/metadata/store.go +168 -0
- package/database/plugin/option.go +190 -0
- package/database/plugin/plugin.go +20 -0
- package/database/plugin/register.go +118 -0
- package/database/pparams.go +145 -0
- package/database/tip.go +45 -0
- package/database/txn.go +147 -0
- package/database/types/types.go +74 -0
- package/database/types/types_test.go +83 -0
- package/database/utxo.go +263 -0
- package/dist/artifacts.json +1 -0
- package/dist/checksums.txt +22 -0
- package/dist/config.yaml +253 -0
- package/dist/dingo-0.5.0-SNAPSHOT-d9431e4.tar.gz +0 -0
- package/dist/dingo-0.5.0-SNAPSHOT-d9431e4.tar.gz.sbom.json +1 -0
- package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_darwin_arm64.tar.gz +0 -0
- package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_darwin_arm64.tar.gz.sbom.json +1 -0
- package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_darwin_x86_64.tar.gz +0 -0
- package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_darwin_x86_64.tar.gz.sbom.json +1 -0
- package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_amd64.apk +0 -0
- package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_amd64.apk.sbom.json +1 -0
- package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_amd64.deb +0 -0
- package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_amd64.deb.sbom.json +1 -0
- package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_amd64.rpm +0 -0
- package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_amd64.rpm.sbom.json +1 -0
- package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_arm64.apk +0 -0
- package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_arm64.apk.sbom.json +1 -0
- package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_arm64.deb +0 -0
- package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_arm64.deb.sbom.json +1 -0
- package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_arm64.rpm +0 -0
- package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_arm64.rpm.sbom.json +1 -0
- package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_arm64.tar.gz +0 -0
- package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_arm64.tar.gz.sbom.json +1 -0
- package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_x86_64.tar.gz +0 -0
- package/dist/dingo_0.5.0-SNAPSHOT-d9431e4_linux_x86_64.tar.gz.sbom.json +1 -0
- package/dist/dingo_darwin_amd64_v1/dingo +0 -0
- package/dist/dingo_darwin_arm64_v8.0/dingo +0 -0
- package/dist/dingo_linux_amd64_v1/dingo +0 -0
- package/dist/dingo_linux_arm64_v8.0/dingo +0 -0
- package/dist/homebrew/dingo.rb +51 -0
- package/dist/metadata.json +1 -0
- package/event/event.go +141 -0
- package/event/event_test.go +115 -0
- package/event/metrics.go +44 -0
- package/go.mod +98 -0
- package/go.sum +358 -0
- package/internal/config/config.go +145 -0
- package/internal/config/config_test.go +118 -0
- package/internal/node/load.go +149 -0
- package/internal/node/node.go +176 -0
- package/internal/version/version.go +33 -0
- package/ledger/certs.go +113 -0
- package/ledger/chainsync.go +578 -0
- package/ledger/eras/allegra.go +154 -0
- package/ledger/eras/alonzo.go +156 -0
- package/ledger/eras/babbage.go +154 -0
- package/ledger/eras/byron.go +42 -0
- package/ledger/eras/conway.go +158 -0
- package/ledger/eras/eras.go +44 -0
- package/ledger/eras/mary.go +154 -0
- package/ledger/eras/shelley.go +164 -0
- package/ledger/error.go +19 -0
- package/ledger/event.go +50 -0
- package/ledger/metrics.go +53 -0
- package/ledger/queries.go +260 -0
- package/ledger/slot.go +127 -0
- package/ledger/slot_test.go +147 -0
- package/ledger/state.go +726 -0
- package/ledger/view.go +73 -0
- package/localstatequery.go +50 -0
- package/localtxmonitor.go +44 -0
- package/localtxsubmission.go +52 -0
- package/mempool/consumer.go +98 -0
- package/mempool/mempool.go +322 -0
- package/node.go +320 -0
- package/package.json +33 -0
- package/peergov/event.go +27 -0
- package/peergov/peer.go +67 -0
- package/peergov/peergov.go +290 -0
- package/peersharing.go +70 -0
- package/preview-local-topology.json +23 -0
- package/topology/topology.go +69 -0
- package/topology/topology_test.go +179 -0
- package/tracing.go +65 -0
- package/txsubmission.go +233 -0
- package/utxorpc/query.go +311 -0
- package/utxorpc/submit.go +395 -0
- package/utxorpc/sync.go +276 -0
- package/utxorpc/utxorpc.go +166 -0
- package/utxorpc/watch.go +310 -0
package/ledger/slot.go
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
// Copyright 2025 Blink Labs Software
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
|
|
15
|
+
package ledger
|
|
16
|
+
|
|
17
|
+
import (
|
|
18
|
+
"errors"
|
|
19
|
+
"math"
|
|
20
|
+
"time"
|
|
21
|
+
|
|
22
|
+
"github.com/blinklabs-io/dingo/database"
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
// SlotToTime returns the current time for a given slot based on known epochs
|
|
26
|
+
func (ls *LedgerState) SlotToTime(slot uint64) (time.Time, error) {
|
|
27
|
+
if slot > math.MaxInt64 {
|
|
28
|
+
return time.Time{}, errors.New("slot is larger than time.Duration")
|
|
29
|
+
}
|
|
30
|
+
shelleyGenesis := ls.config.CardanoNodeConfig.ShelleyGenesis()
|
|
31
|
+
if shelleyGenesis == nil {
|
|
32
|
+
return time.Time{}, errors.New("could not get genesis config")
|
|
33
|
+
}
|
|
34
|
+
slotTime := shelleyGenesis.SystemStart
|
|
35
|
+
// Special case for chain genesis
|
|
36
|
+
if slot == 0 {
|
|
37
|
+
return slotTime, nil
|
|
38
|
+
}
|
|
39
|
+
foundSlot := false
|
|
40
|
+
for _, epoch := range ls.epochCache {
|
|
41
|
+
if epoch.StartSlot > math.MaxInt64 ||
|
|
42
|
+
epoch.LengthInSlots > math.MaxInt64 ||
|
|
43
|
+
epoch.SlotLength > math.MaxInt64 {
|
|
44
|
+
return time.Time{}, errors.New(
|
|
45
|
+
"epoch slot values are larger than time.Duration",
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
if slot < epoch.StartSlot+uint64(epoch.LengthInSlots) {
|
|
49
|
+
slotTime = slotTime.Add(
|
|
50
|
+
time.Duration(
|
|
51
|
+
int64(slot)-int64(epoch.StartSlot),
|
|
52
|
+
) * (time.Duration(epoch.SlotLength) * time.Millisecond),
|
|
53
|
+
)
|
|
54
|
+
foundSlot = true
|
|
55
|
+
break
|
|
56
|
+
}
|
|
57
|
+
slotTime = slotTime.Add(
|
|
58
|
+
time.Duration(
|
|
59
|
+
epoch.LengthInSlots,
|
|
60
|
+
) * (time.Duration(epoch.SlotLength) * time.Millisecond),
|
|
61
|
+
)
|
|
62
|
+
}
|
|
63
|
+
if !foundSlot {
|
|
64
|
+
return slotTime, errors.New("slot not found in known epochs")
|
|
65
|
+
}
|
|
66
|
+
return slotTime, nil
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// TimeToSlot returns the slot number for a given time based on known epochs
|
|
70
|
+
func (ls *LedgerState) TimeToSlot(t time.Time) (uint64, error) {
|
|
71
|
+
shelleyGenesis := ls.config.CardanoNodeConfig.ShelleyGenesis()
|
|
72
|
+
if shelleyGenesis == nil {
|
|
73
|
+
return 0, errors.New("could not get genesis config")
|
|
74
|
+
}
|
|
75
|
+
epochStartTime := shelleyGenesis.SystemStart
|
|
76
|
+
// Special case for chain genesis
|
|
77
|
+
if t.Equal(epochStartTime) {
|
|
78
|
+
return 0, nil
|
|
79
|
+
}
|
|
80
|
+
var timeSlot uint64
|
|
81
|
+
foundTime := false
|
|
82
|
+
for _, epoch := range ls.epochCache {
|
|
83
|
+
if epoch.LengthInSlots > math.MaxInt64 ||
|
|
84
|
+
epoch.SlotLength > math.MaxInt64 {
|
|
85
|
+
return 0, errors.New(
|
|
86
|
+
"epoch slot values are larger than time.Duration",
|
|
87
|
+
)
|
|
88
|
+
}
|
|
89
|
+
slotDuration := time.Duration(epoch.SlotLength) * time.Millisecond
|
|
90
|
+
if slotDuration < 0 {
|
|
91
|
+
return 0, errors.New("slot duration is negative")
|
|
92
|
+
}
|
|
93
|
+
epochEndTime := epochStartTime.Add(
|
|
94
|
+
time.Duration(epoch.LengthInSlots) * slotDuration,
|
|
95
|
+
)
|
|
96
|
+
if (t.Equal(epochStartTime) || t.After(epochStartTime)) &&
|
|
97
|
+
t.Before(epochEndTime) {
|
|
98
|
+
// Figure out how far into the epoch the specified time is
|
|
99
|
+
timeDiff := t.Sub(epochStartTime)
|
|
100
|
+
// nolint:gosec
|
|
101
|
+
// This will never overflow using 2 positive int64 values, but gosec seems determined
|
|
102
|
+
// to complain about it
|
|
103
|
+
timeSlot += uint64(timeDiff / slotDuration)
|
|
104
|
+
foundTime = true
|
|
105
|
+
break
|
|
106
|
+
}
|
|
107
|
+
epochStartTime = epochEndTime
|
|
108
|
+
timeSlot += uint64(epoch.LengthInSlots)
|
|
109
|
+
}
|
|
110
|
+
if !foundTime {
|
|
111
|
+
return timeSlot, errors.New("time not found in known epochs")
|
|
112
|
+
}
|
|
113
|
+
return timeSlot, nil
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// SlotToEpoch returns a known epoch by slot number
|
|
117
|
+
func (ls *LedgerState) SlotToEpoch(slot uint64) (database.Epoch, error) {
|
|
118
|
+
for _, epoch := range ls.epochCache {
|
|
119
|
+
if slot < epoch.StartSlot {
|
|
120
|
+
continue
|
|
121
|
+
}
|
|
122
|
+
if slot < epoch.StartSlot+uint64(epoch.LengthInSlots) {
|
|
123
|
+
return epoch, nil
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return database.Epoch{}, errors.New("slot not found in known epochs")
|
|
127
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
// Copyright 2025 Blink Labs Software
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
|
|
15
|
+
package ledger
|
|
16
|
+
|
|
17
|
+
import (
|
|
18
|
+
"strings"
|
|
19
|
+
"testing"
|
|
20
|
+
"time"
|
|
21
|
+
|
|
22
|
+
"github.com/blinklabs-io/dingo/config/cardano"
|
|
23
|
+
"github.com/blinklabs-io/dingo/database"
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
func TestSlotCalc(t *testing.T) {
|
|
27
|
+
testLedgerState := &LedgerState{
|
|
28
|
+
epochCache: []database.Epoch{
|
|
29
|
+
{
|
|
30
|
+
EpochId: 0,
|
|
31
|
+
StartSlot: 0,
|
|
32
|
+
SlotLength: 1000,
|
|
33
|
+
LengthInSlots: 86400,
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
EpochId: 1,
|
|
37
|
+
StartSlot: 86400,
|
|
38
|
+
SlotLength: 1000,
|
|
39
|
+
LengthInSlots: 86400,
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
EpochId: 2,
|
|
43
|
+
StartSlot: 172800,
|
|
44
|
+
SlotLength: 1000,
|
|
45
|
+
LengthInSlots: 86400,
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
EpochId: 3,
|
|
49
|
+
StartSlot: 259200,
|
|
50
|
+
SlotLength: 1000,
|
|
51
|
+
LengthInSlots: 86400,
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
EpochId: 4,
|
|
55
|
+
StartSlot: 345600,
|
|
56
|
+
SlotLength: 1000,
|
|
57
|
+
LengthInSlots: 86400,
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
EpochId: 5,
|
|
61
|
+
StartSlot: 432000,
|
|
62
|
+
SlotLength: 1000,
|
|
63
|
+
LengthInSlots: 86400,
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
config: LedgerStateConfig{
|
|
67
|
+
CardanoNodeConfig: &cardano.CardanoNodeConfig{},
|
|
68
|
+
},
|
|
69
|
+
}
|
|
70
|
+
testShelleyGenesis := `{"systemStart": "2022-10-25T00:00:00Z"}`
|
|
71
|
+
if err := testLedgerState.config.CardanoNodeConfig.LoadShelleyGenesisFromReader(strings.NewReader(testShelleyGenesis)); err != nil {
|
|
72
|
+
t.Fatalf("unexpected error loading cardano node config: %s", err)
|
|
73
|
+
}
|
|
74
|
+
testDefs := []struct {
|
|
75
|
+
slot uint64
|
|
76
|
+
slotTime time.Time
|
|
77
|
+
epoch uint64
|
|
78
|
+
}{
|
|
79
|
+
{
|
|
80
|
+
slot: 0,
|
|
81
|
+
slotTime: time.Date(2022, time.October, 25, 0, 0, 0, 0, time.UTC),
|
|
82
|
+
epoch: 0,
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
slot: 86399,
|
|
86
|
+
slotTime: time.Date(
|
|
87
|
+
2022,
|
|
88
|
+
time.October,
|
|
89
|
+
25,
|
|
90
|
+
23,
|
|
91
|
+
59,
|
|
92
|
+
59,
|
|
93
|
+
0,
|
|
94
|
+
time.UTC,
|
|
95
|
+
),
|
|
96
|
+
epoch: 0,
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
slot: 86400,
|
|
100
|
+
slotTime: time.Date(2022, time.October, 26, 0, 0, 0, 0, time.UTC),
|
|
101
|
+
epoch: 1,
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
slot: 432001,
|
|
105
|
+
slotTime: time.Date(2022, time.October, 30, 0, 0, 1, 0, time.UTC),
|
|
106
|
+
epoch: 5,
|
|
107
|
+
},
|
|
108
|
+
}
|
|
109
|
+
for _, testDef := range testDefs {
|
|
110
|
+
// Slot to time
|
|
111
|
+
tmpSlotToTime, err := testLedgerState.SlotToTime(testDef.slot)
|
|
112
|
+
if err != nil {
|
|
113
|
+
t.Errorf("unexpected error converting slot to time: %s", err)
|
|
114
|
+
}
|
|
115
|
+
if !tmpSlotToTime.Equal(testDef.slotTime) {
|
|
116
|
+
t.Errorf(
|
|
117
|
+
"did not get expected time from slot: got %s, wanted %s",
|
|
118
|
+
tmpSlotToTime,
|
|
119
|
+
testDef.slotTime,
|
|
120
|
+
)
|
|
121
|
+
}
|
|
122
|
+
// Time to slot
|
|
123
|
+
tmpTimeToSlot, err := testLedgerState.TimeToSlot(testDef.slotTime)
|
|
124
|
+
if err != nil {
|
|
125
|
+
t.Errorf("unexpected error converting time to slot: %s", err)
|
|
126
|
+
}
|
|
127
|
+
if tmpTimeToSlot != testDef.slot {
|
|
128
|
+
t.Errorf(
|
|
129
|
+
"did not get expected slot from time: got %d, wanted %d",
|
|
130
|
+
tmpTimeToSlot,
|
|
131
|
+
testDef.slot,
|
|
132
|
+
)
|
|
133
|
+
}
|
|
134
|
+
// Slot to epoch
|
|
135
|
+
tmpSlotToEpoch, err := testLedgerState.SlotToEpoch(testDef.slot)
|
|
136
|
+
if err != nil {
|
|
137
|
+
t.Errorf("unexpected error getting epoch from slot: %s", err)
|
|
138
|
+
}
|
|
139
|
+
if tmpSlotToEpoch.EpochId != testDef.epoch {
|
|
140
|
+
t.Errorf(
|
|
141
|
+
"did not get expected epoch from slot: got %d, wanted %d",
|
|
142
|
+
tmpSlotToEpoch.EpochId,
|
|
143
|
+
testDef.epoch,
|
|
144
|
+
)
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|