-
Notifications
You must be signed in to change notification settings - Fork 17
/
upgrade_test.go
63 lines (47 loc) · 1.48 KB
/
upgrade_test.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
62
63
//go:build bdd
package emoney_test
import (
nt "github.com/e-money/em-ledger/networktest"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/tidwall/gjson"
)
var _ = Describe("Upgrade", func() {
emcli := testnet.NewEmcli()
Authority := testnet.Keystore.Authority
Describe("Authority manages issuers", func() {
It("creates a new testnet", createNewTestnet)
It("upgrade nodes and confirm", func() {
const (
name = "test-upg-0.2.0"
)
chainHeight, err := nt.GetHeight()
Expect(err).ToNot(HaveOccurred())
const upgDelta = 4
upgHeight := chainHeight + upgDelta
_, success, err := emcli.UpgSchedByHeight(Authority, name,
upgHeight,
)
Expect(err).ToNot(HaveOccurred())
Expect(success).To(BeTrue())
bz, err := emcli.QueryUpgSched()
Expect(err).ToNot(HaveOccurred())
upgPlan := gjson.ParseBytes(bz).Get("plan")
resName := upgPlan.Get("name").Str
Expect(resName).To(Equal(name))
resUpgHeight := upgPlan.Get("height").Int()
Expect(resUpgHeight).To(BeEquivalentTo(upgHeight))
// wait till the upgrade
newHeight, err := nt.IncChain(upgDelta)
Expect(err).ToNot(HaveOccurred())
Expect(newHeight >= upgHeight).To(BeTrue())
// if we made it here, the upgrade succeeded
bz, err = emcli.QueryUpgSched()
Expect(err).ToNot(HaveOccurred())
// assert that the upgrade plan zeroed out
upgPlan = gjson.ParseBytes(bz).Get("plan")
resName = upgPlan.Get("name").Str
Expect(resName).To(HaveLen(0))
})
})
})