-
Notifications
You must be signed in to change notification settings - Fork 375
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(keeper)!: use <pkgpath>.<expr> syntax for qeval; <pkgpath>:<path…
…> for qrender (#2382) This is a switch that was discussed with @leohhhn and @moul. It switches the current syntax for qeval, which requires a newline as a separator, to use a dot `.` instead (ie. `gno.land/r/demo/users.MyFunction(123)`). For qrender, this is switched to a colon `:`, like the gnoweb render: `gno.land/r/demo/users:u/morgan`. BREAKING CHANGE: current qeval and qrender calls using the RPC endpoints will have to be changed. No changes are required for gnoclient users. <details><summary>Contributors' checklist...</summary> - [x] Added new tests, or not needed, or not feasible - [x] Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory - [x] Updated the official documentation or not needed - [x] No breaking changes were made, or a `BREAKING CHANGE: xxx` message was included in the description - [x] Added references to related issues and PRs - [x] Provided any useful hints for running manual tests - [x] Added new benchmarks to [generated graphs](https://gnoland.github.io/benchmarks), if any. More info [here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md). </details> --------- Co-authored-by: Manfred Touron <94029+moul@users.noreply.github.com> Co-authored-by: Leon Hudak <33522493+leohhhn@users.noreply.github.com>
- Loading branch information
1 parent
d2d34eb
commit 032d422
Showing
8 changed files
with
90 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,50 @@ | ||
package vm | ||
|
||
/* | ||
import ( | ||
"fmt" | ||
"strings" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
"github.com/gnolang/gno/tm2/pkg/amino" | ||
abci "github.com/gnolang/gno/tm2/pkg/bft/abci/types" | ||
bft "github.com/gnolang/gno/tm2/pkg/bft/types" | ||
"github.com/gnolang/gno/tm2/pkg/sdk" | ||
tu "github.com/gnolang/gno/tm2/pkg/sdk/testutils" | ||
"github.com/gnolang/gno/tm2/pkg/std" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestInvalidMsg(t *testing.T) { | ||
h := NewHandler(BankKeeper{}) | ||
res := h.Process(sdk.NewContext(nil, &bft.Header{}, false, nil), tu.NewTestMsg()) | ||
require.False(t, res.IsOK()) | ||
require.True(t, strings.Contains(res.Log, "unrecognized bank message type")) | ||
} | ||
func TestBalances(t *testing.T) { | ||
env := setupTestEnv() | ||
h := NewHandler(env.bank) | ||
req := abci.RequestQuery{ | ||
Path: fmt.Sprintf("bank/%s", QueryBalance), | ||
Data: []byte{}, | ||
func Test_parseQueryEvalData(t *testing.T) { | ||
t.Parallel() | ||
tt := []struct { | ||
input string | ||
pkgpath string | ||
expr string | ||
}{ | ||
{ | ||
"gno.land/r/realm.Expression()", | ||
"gno.land/r/realm", | ||
"Expression()", | ||
}, | ||
{ | ||
"a.b/c/d.e", | ||
"a.b/c/d", | ||
"e", | ||
}, | ||
{ | ||
"a.b.c.d.e/c/d.e", | ||
"a.b.c.d.e/c/d", | ||
"e", | ||
}, | ||
{ | ||
"abcde/c/d.e", | ||
"abcde/c/d", | ||
"e", | ||
}, | ||
} | ||
for _, tc := range tt { | ||
path, expr := parseQueryEvalData(tc.input) | ||
assert.Equal(t, tc.pkgpath, path) | ||
assert.Equal(t, tc.expr, expr) | ||
} | ||
} | ||
|
||
res := h.Query(env.ctx, req) | ||
require.NotNil(t, res.Error) | ||
_, _, addr := tu.KeyTestPubAddr() | ||
req.Data = amino.MustMarshalJSON(NewQueryBalanceParams(addr)) | ||
res = h.Query(env.ctx, req) | ||
require.Nil(t, res.Error) // the account does not exist, no error returned anyway | ||
require.NotNil(t, res) | ||
var coins std.Coins | ||
require.NoError(t, amino.UnmarshalJSON(res.Data, &coins)) | ||
require.True(t, coins.IsZero()) | ||
func Test_parseQueryEval_panic(t *testing.T) { | ||
t.Parallel() | ||
|
||
acc := env.acck.NewAccountWithAddress(env.ctx, addr) | ||
acc.SetCoins(std.NewCoins(std.NewCoin("foo", 10))) | ||
env.acck.SetAccount(env.ctx, acc) | ||
res = h.Query(env.ctx, req) | ||
require.Nil(t, res.Error) | ||
require.NotNil(t, res) | ||
require.NoError(t, amino.UnmarshalJSON(res.Data, &coins)) | ||
require.True(t, coins.AmountOf("foo") == 10) | ||
assert.PanicsWithValue(t, panicInvalidQueryEvalData, func() { | ||
parseQueryEvalData("gno.land/r/demo/users") | ||
}) | ||
} | ||
*/ |