rpc/client: add support for notification filters

Differing a bit from #895 draft specification, we won't add `sender` or
`cosigner` to `transaction_executed`.
This commit is contained in:
Roman Khimov 2020-05-13 13:16:42 +03:00
parent c4c080d240
commit 725b47ddef
4 changed files with 283 additions and 42 deletions

View file

@ -13,7 +13,15 @@ import (
)
func TestParam_UnmarshalJSON(t *testing.T) {
msg := `["str1", 123, ["str2", 3], [{"type": "String", "value": "jajaja"}]]`
msg := `["str1", 123, ["str2", 3], [{"type": "String", "value": "jajaja"}],
{"primary": 1},
{"sender": "f84d6a337fbc3d3a201d41da99e86b479e7a2554"},
{"cosigner": "f84d6a337fbc3d3a201d41da99e86b479e7a2554"},
{"sender": "f84d6a337fbc3d3a201d41da99e86b479e7a2554", "cosigner": "f84d6a337fbc3d3a201d41da99e86b479e7a2554"},
{"contract": "f84d6a337fbc3d3a201d41da99e86b479e7a2554"},
{"state": "HALT"}]`
contr, err := util.Uint160DecodeStringLE("f84d6a337fbc3d3a201d41da99e86b479e7a2554")
require.NoError(t, err)
expected := Params{
{
Type: StringT,
@ -51,6 +59,30 @@ func TestParam_UnmarshalJSON(t *testing.T) {
},
},
},
{
Type: BlockFilterT,
Value: BlockFilter{Primary: 1},
},
{
Type: TxFilterT,
Value: TxFilter{Sender: &contr},
},
{
Type: TxFilterT,
Value: TxFilter{Cosigner: &contr},
},
{
Type: TxFilterT,
Value: TxFilter{Sender: &contr, Cosigner: &contr},
},
{
Type: NotificationFilterT,
Value: NotificationFilter{Contract: contr},
},
{
Type: ExecutionFilterT,
Value: ExecutionFilter{State: "HALT"},
},
}
var ps Params