5
5
"testing"
6
6
"time"
7
7
8
+ "github.com/stretchr/testify/require"
9
+
8
10
"github.com/hyperledger/burrow/acm"
9
11
"github.com/hyperledger/burrow/acm/validator"
10
12
"github.com/hyperledger/burrow/permission"
@@ -33,6 +35,16 @@ func TestMakeGenesisDocFromAccounts(t *testing.T) {
33
35
assert .Equal (t , genDoc .Hash (), genDocOut .Hash ())
34
36
fmt .Println (string (bs ))
35
37
}
38
+ func TestGenesisStability (t * testing.T ) {
39
+ genDoc := MakeGenesisDocFromAccounts ("test-chain" , nil , genesisTime ,
40
+ accountMap ("Tinkie-winkie" , "Lala" , "Po" , "Dipsy" ),
41
+ validatorMap ("Foo" , "Bar" , "Baz" ),
42
+ )
43
+
44
+ require .Equal (t , expectedGenesisJSON , genDoc .JSONString ())
45
+
46
+ require .Equal (t , "C5B64E6AD231221C328271ADCE401AA11F9DF12830F7DA2FC3B2C923E929C532" , genDoc .Hash ().String ())
47
+ }
36
48
37
49
func accountMap (names ... string ) map [string ]* acm.Account {
38
50
accounts := make (map [string ]* acm.Account , len (names ))
@@ -59,3 +71,118 @@ func accountFromName(name string) *acm.Account {
59
71
ca .Permissions = permission .AllAccountPermissions .Clone ()
60
72
return ca
61
73
}
74
+
75
+ // For genesis stability test
76
+ const expectedGenesisJSON = `{
77
+ "GenesisTime": "2017-10-27T00:00:00Z",
78
+ "ChainName": "test-chain",
79
+ "Params": {
80
+ "ProposalThreshold": 0
81
+ },
82
+ "GlobalPermissions": {
83
+ "Base": {
84
+ "Perms": "send | call | createContract | createAccount | bond | name | proposal | input | batch | hasBase | hasRole",
85
+ "SetBit": "root | send | call | createContract | createAccount | bond | name | proposal | input | batch | identify | hasBase | setBase | unsetBase | setGlobal | hasRole | addRole | removeRole"
86
+ }
87
+ },
88
+ "Accounts": [
89
+ {
90
+ "Address": "410427F4A361B958C97B47D81DAFDCF0A2B6503D",
91
+ "PublicKey": null,
92
+ "Amount": 521,
93
+ "Name": "Dipsy",
94
+ "Permissions": {
95
+ "Base": {
96
+ "Perms": "root | send | call | createContract | createAccount | bond | name | proposal | input | batch | identify | hasBase | setBase | unsetBase | setGlobal | hasRole | addRole | removeRole",
97
+ "SetBit": "root | send | call | createContract | createAccount | bond | name | proposal | input | batch | identify | hasBase | setBase | unsetBase | setGlobal | hasRole | addRole | removeRole"
98
+ }
99
+ }
100
+ },
101
+ {
102
+ "Address": "1815E3667F406CA3872234D2573014CDE6CD2ABC",
103
+ "PublicKey": null,
104
+ "Amount": 378,
105
+ "Name": "Lala",
106
+ "Permissions": {
107
+ "Base": {
108
+ "Perms": "root | send | call | createContract | createAccount | bond | name | proposal | input | batch | identify | hasBase | setBase | unsetBase | setGlobal | hasRole | addRole | removeRole",
109
+ "SetBit": "root | send | call | createContract | createAccount | bond | name | proposal | input | batch | identify | hasBase | setBase | unsetBase | setGlobal | hasRole | addRole | removeRole"
110
+ }
111
+ }
112
+ },
113
+ {
114
+ "Address": "A8174022832E4BA1BB52B380128514F72FB2FEBD",
115
+ "PublicKey": null,
116
+ "Amount": 191,
117
+ "Name": "Po",
118
+ "Permissions": {
119
+ "Base": {
120
+ "Perms": "root | send | call | createContract | createAccount | bond | name | proposal | input | batch | identify | hasBase | setBase | unsetBase | setGlobal | hasRole | addRole | removeRole",
121
+ "SetBit": "root | send | call | createContract | createAccount | bond | name | proposal | input | batch | identify | hasBase | setBase | unsetBase | setGlobal | hasRole | addRole | removeRole"
122
+ }
123
+ }
124
+ },
125
+ {
126
+ "Address": "8979C634DFD2F6D20975EBE02C34B5E9C280AB18",
127
+ "PublicKey": null,
128
+ "Amount": 1304,
129
+ "Name": "Tinkie-winkie",
130
+ "Permissions": {
131
+ "Base": {
132
+ "Perms": "root | send | call | createContract | createAccount | bond | name | proposal | input | batch | identify | hasBase | setBase | unsetBase | setGlobal | hasRole | addRole | removeRole",
133
+ "SetBit": "root | send | call | createContract | createAccount | bond | name | proposal | input | batch | identify | hasBase | setBase | unsetBase | setGlobal | hasRole | addRole | removeRole"
134
+ }
135
+ }
136
+ }
137
+ ],
138
+ "Validators": [
139
+ {
140
+ "Address": "29BB63AD75E2DA3368FC823DC68C01CF1FA87190",
141
+ "PublicKey": {
142
+ "CurveType": "ed25519",
143
+ "PublicKey": "A18679ADC4391630178AC0DB35A115BEAEDA38B3DEABF92AC5FDE31A748DC259"
144
+ },
145
+ "Amount": 277,
146
+ "Name": "Bar",
147
+ "UnbondTo": [
148
+ {
149
+ "Address": "29BB63AD75E2DA3368FC823DC68C01CF1FA87190",
150
+ "PublicKey": null,
151
+ "Amount": 277
152
+ }
153
+ ]
154
+ },
155
+ {
156
+ "Address": "C92303227C9F0EC569B27B02DB328CFA0A7DF7E0",
157
+ "PublicKey": {
158
+ "CurveType": "ed25519",
159
+ "PublicKey": "E3C56A2C047C9C82036778620E6F9089E5FB38A5D36CE47D9545CBA930C79522"
160
+ },
161
+ "Amount": 285,
162
+ "Name": "Baz",
163
+ "UnbondTo": [
164
+ {
165
+ "Address": "C92303227C9F0EC569B27B02DB328CFA0A7DF7E0",
166
+ "PublicKey": null,
167
+ "Amount": 285
168
+ }
169
+ ]
170
+ },
171
+ {
172
+ "Address": "900EBED8C6B27F7B606B6CAD34DB03C2C5C0E541",
173
+ "PublicKey": {
174
+ "CurveType": "ed25519",
175
+ "PublicKey": "78133DE07C66C616263FD2D6A54BD3FC0D8CBF3A87BB2E0C410A0C8DEB6189CE"
176
+ },
177
+ "Amount": 292,
178
+ "Name": "Foo",
179
+ "UnbondTo": [
180
+ {
181
+ "Address": "900EBED8C6B27F7B606B6CAD34DB03C2C5C0E541",
182
+ "PublicKey": null,
183
+ "Amount": 292
184
+ }
185
+ ]
186
+ }
187
+ ]
188
+ }`
0 commit comments