forked from stellar/go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
61 lines (52 loc) · 1.29 KB
/
main.go
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
package main
import (
"fmt"
"github.com/aiblocks/go/ingest/ledgerbackend"
)
// This little app helped testing CaptiveAiBlocksCore.runFromParams on a living
// AiBlocks-Core. Adding it to the repo because it can be useful in a future if
// AiBlocks-Core behaviour changes again.
// To make it work, run standalone network (RUN_STANDALONE=false to allow outside
// connections) and update paths below.
func main() {
// check(1) // err expected, cannot stream in captive core
checkLedgers := []uint32{2, 3, 62, 63, 64, 65, 126, 127, 128}
for _, ledger := range checkLedgers {
ok := check(ledger)
if !ok {
panic("test failed error")
}
}
}
func check(ledger uint32) bool {
c, err := ledgerbackend.NewCaptive(
"aiblocks-core",
"aiblocks-core-standalone2.cfg",
"Standalone Network ; February 2017",
[]string{"http://localhost:1570"},
)
if err != nil {
panic(err)
}
defer c.Close()
err = c.PrepareRange(ledgerbackend.UnboundedRange(ledger))
if err != nil {
fmt.Println(err)
return false
}
ok, meta, err := c.GetLedger(ledger)
if err != nil {
fmt.Println(err)
return false
}
if !ok {
fmt.Println("no ledger")
return false
}
if meta.LedgerSequence() != ledger {
fmt.Println("wrong ledger", meta.LedgerSequence())
return false
}
fmt.Println(ledger, "ok")
return true
}