diff --git a/x/programs/examples/token.go b/x/programs/examples/token.go index 8f3bb1a4b4..7bc67c3bb7 100644 --- a/x/programs/examples/token.go +++ b/x/programs/examples/token.go @@ -175,6 +175,11 @@ func (t *Token) Run(ctx context.Context) error { zap.Int64("alice", mintAlice), ) + alicePtr, err = writeToMem(alicePublicKey, mem) + if err != nil { + return err + } + // check balance of alice result, err = rt.Call(ctx, "get_balance", programContext, alicePtr) if err != nil { @@ -184,6 +189,11 @@ func (t *Token) Run(ctx context.Context) error { zap.Int64("alice", result[0]), ) + bobPtr, err = writeToMem(bobPublicKey, mem) + if err != nil { + return err + } + // check balance of bob result, err = rt.Call(ctx, "get_balance", programContext, bobPtr) if err != nil { @@ -199,6 +209,16 @@ func (t *Token) Run(ctx context.Context) error { if err != nil { return err } + bobPtr, err = writeToMem(bobPublicKey, mem) + if err != nil { + return err + } + + alicePtr, err = writeToMem(alicePublicKey, mem) + if err != nil { + return err + } + _, err = rt.Call(ctx, "transfer", programContext, alicePtr, bobPtr, transferToBobPtr) if err != nil { return err @@ -213,6 +233,16 @@ func (t *Token) Run(ctx context.Context) error { return err } + bobPtr, err = writeToMem(bobPublicKey, mem) + if err != nil { + return err + } + + alicePtr, err = writeToMem(alicePublicKey, mem) + if err != nil { + return err + } + _, err = rt.Call(ctx, "transfer", programContext, alicePtr, bobPtr, onePtr) if err != nil { return err @@ -222,6 +252,11 @@ func (t *Token) Run(ctx context.Context) error { zap.Int64("to bob", 1), ) + alicePtr, err = writeToMem(alicePublicKey, mem) + if err != nil { + return err + } + // get balance alice result, err = rt.Call(ctx, "get_balance", programContext, alicePtr) if err != nil { @@ -231,6 +266,11 @@ func (t *Token) Run(ctx context.Context) error { zap.Int64("alice", result[0]), ) + bobPtr, err = writeToMem(bobPublicKey, mem) + if err != nil { + return err + } + // get balance bob result, err = rt.Call(ctx, "get_balance", programContext, bobPtr) if err != nil { @@ -274,6 +314,11 @@ func (t *Token) Run(ctx context.Context) error { zap.Int32("to bob", minters[1].Amount), ) + alicePtr, err = writeToMem(alicePublicKey, mem) + if err != nil { + return err + } + // get balance alice result, err = rt.Call(ctx, "get_balance", programContext, alicePtr) if err != nil { @@ -283,6 +328,11 @@ func (t *Token) Run(ctx context.Context) error { zap.Int64("alice", result[0]), ) + bobPtr, err = writeToMem(bobPublicKey, mem) + if err != nil { + return err + } + // get balance bob result, err = rt.Call(ctx, "get_balance", programContext, bobPtr) if err != nil { diff --git a/x/programs/examples/token_test.go b/x/programs/examples/token_test.go index f4977e842e..58a37358c5 100644 --- a/x/programs/examples/token_test.go +++ b/x/programs/examples/token_test.go @@ -65,6 +65,9 @@ func TestTokenProgram(t *testing.T) { _, err = rt.Call(ctx, "mint_to", callContext, alicePtr, mintAlicePtr) require.NoError(err) + alicePtr, err = writeToMem(alicePublicKey, mem) + require.NoError(err) + // check balance of alice result, err := rt.Call(ctx, "get_balance", callContext, alicePtr) require.NoError(err) @@ -75,6 +78,9 @@ func TestTokenProgram(t *testing.T) { require.NoError(err) require.Equal(int64(1000), aliceBalance) + alicePtr, err = writeToMem(alicePublicKey, mem) + require.NoError(err) + // burn alice tokens _, err = rt.Call(ctx, "burn_from", callContext, alicePtr) require.NoError(err) diff --git a/x/programs/tests/fixture/token.wasm b/x/programs/tests/fixture/token.wasm index 35a7de0673..9d30138ce0 100755 Binary files a/x/programs/tests/fixture/token.wasm and b/x/programs/tests/fixture/token.wasm differ