Skip to content

Commit 0cc9a9b

Browse files
committedApr 4, 2022
fixed sdk vm keeper tests
1 parent 06ab78a commit 0cc9a9b

File tree

5 files changed

+45
-7
lines changed

5 files changed

+45
-7
lines changed
 

‎TODO.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
-> re staking:
4242

4343
* run realm tests with debug on.
44-
* vm keeper should not use ante-handler gas upon restart. (...)
44+
* vm keeper should not use ante-handler gas upon restart. (DONE)
4545
* write new test case for newreal newdeleted bug. (DONE)
4646
* make account number not change for new packages... (WONT DO)
4747
* test functionality of invites again. (DONE)

‎pkgs/sdk/vm/common_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,7 @@ func setupTestEnv() testEnv {
3939
bank := bankm.NewBankKeeper(acck)
4040
vmk := NewVMKeeper(baseCapKey, iavlCapKey, acck, bank, "../../../stdlibs")
4141

42+
vmk.Initialize(ms.MultiCacheWrap())
43+
4244
return testEnv{ctx: ctx, vmk: vmk, bank: bank, acck: acck}
4345
}

‎pkgs/sdk/vm/keeper_test.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func TestVMKeeperTxSend1(t *testing.T) {
2424
assert.True(t, env.bank.GetCoins(ctx, addr).IsEqual(std.MustParseCoins("10gnot")))
2525

2626
// Create test package.
27-
files := []std.MemFile{
27+
files := []*std.MemFile{
2828
{"init.go", `
2929
package test
3030
@@ -33,7 +33,7 @@ import "std"
3333
func init() {
3434
}
3535
36-
func Echo(msg string) string Orig{
36+
func Echo(msg string) string {
3737
addr := std.GetOrigCaller()
3838
pkgAddr := std.GetOrigPkgAddr()
3939
send := std.GetTxSendCoins()
@@ -69,7 +69,7 @@ func TestVMKeeperTxSend2(t *testing.T) {
6969
assert.True(t, env.bank.GetCoins(ctx, addr).IsEqual(std.MustParseCoins("10gnot")))
7070

7171
// Create test package.
72-
files := []std.MemFile{
72+
files := []*std.MemFile{
7373
{"init.go", `
7474
package test
7575
@@ -115,7 +115,7 @@ func TestVMKeeperTxSend3(t *testing.T) {
115115
assert.True(t, env.bank.GetCoins(ctx, addr).IsEqual(std.MustParseCoins("10gnot")))
116116

117117
// Create test package.
118-
files := []std.MemFile{
118+
files := []*std.MemFile{
119119
{"init.go", `
120120
package test
121121
@@ -160,7 +160,7 @@ func TestVMKeeperRealmSend1(t *testing.T) {
160160
assert.True(t, env.bank.GetCoins(ctx, addr).IsEqual(std.MustParseCoins("10gnot")))
161161

162162
// Create test package.
163-
files := []std.MemFile{
163+
files := []*std.MemFile{
164164
{"init.go", `
165165
package test
166166
@@ -204,7 +204,7 @@ func TestVMKeeperRealmSend2(t *testing.T) {
204204
assert.True(t, env.bank.GetCoins(ctx, addr).IsEqual(std.MustParseCoins("10gnot")))
205205

206206
// Create test package.
207-
files := []std.MemFile{
207+
files := []*std.MemFile{
208208
{"init.go", `
209209
package test
210210

‎tests/files/composite17.go

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package main
2+
3+
type Struct struct {
4+
Field string
5+
}
6+
7+
func main() {
8+
var x []*Struct = []*Struct{
9+
{"foobar"},
10+
{"barbaz"},
11+
}
12+
println(x[0].Field)
13+
println(x[1].Field)
14+
}
15+
16+
// Output:
17+
// foobar
18+
// barbaz

‎tests/files2/composite17.go

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package main
2+
3+
type Struct struct {
4+
Field string
5+
}
6+
7+
func main() {
8+
var x []*Struct = []*Struct{
9+
{"foobar"},
10+
{"barbaz"},
11+
}
12+
println(x[0].Field)
13+
println(x[1].Field)
14+
}
15+
16+
// Output:
17+
// foobar
18+
// barbaz

0 commit comments

Comments
 (0)
Please sign in to comment.