Update eth_subscribe itests to work with correct responses

This commit is contained in:
Łukasz Magiera 2023-02-08 15:59:08 +01:00
parent 3516c7674b
commit c2e3832643

View File

@ -563,11 +563,7 @@ func TestEthSubscribeLogs(t *testing.T) {
var elogs []*ethtypes.EthLog var elogs []*ethtypes.EthLog
for resp := range responseCh { for resp := range responseCh {
rlist, ok := resp.Result.([]interface{}) rmap, ok := resp.Result.(map[string]interface{})
require.True(ok, "expected subscription result to be []interface{}, but was %T", resp.Result)
for _, rentry := range rlist {
rmap, ok := rentry.(map[string]interface{})
require.True(ok, "expected subscription result entry to be map[string]interface{}, but was %T", resp.Result) require.True(ok, "expected subscription result entry to be map[string]interface{}, but was %T", resp.Result)
elog, err := ParseEthLog(rmap) elog, err := ParseEthLog(rmap)
@ -575,8 +571,6 @@ func TestEthSubscribeLogs(t *testing.T) {
elogs = append(elogs, elog) elogs = append(elogs, elog)
} }
}
AssertEthLogs(t, elogs, tc.expected, messages) AssertEthLogs(t, elogs, tc.expected, messages)
}) })
} }
@ -1966,15 +1960,9 @@ func AssertEthLogs(t *testing.T, actual []*ethtypes.EthLog, expected []ExpectedE
func parseEthLogsFromSubscriptionResponses(subResponses []ethtypes.EthSubscriptionResponse) ([]*ethtypes.EthLog, error) { func parseEthLogsFromSubscriptionResponses(subResponses []ethtypes.EthSubscriptionResponse) ([]*ethtypes.EthLog, error) {
elogs := make([]*ethtypes.EthLog, 0, len(subResponses)) elogs := make([]*ethtypes.EthLog, 0, len(subResponses))
for i := range subResponses { for i := range subResponses {
rlist, ok := subResponses[i].Result.([]interface{}) rmap, ok := subResponses[i].Result.(map[string]interface{})
if !ok { if !ok {
return nil, xerrors.Errorf("expected subscription result to be []interface{}, but was %T", subResponses[i].Result) return nil, xerrors.Errorf("expected subscription result entry to be map[string]interface{}, but was %T", subResponses[i].Result)
}
for _, r := range rlist {
rmap, ok := r.(map[string]interface{})
if !ok {
return nil, xerrors.Errorf("expected subscription result entry to be map[string]interface{}, but was %T", r)
} }
elog, err := ParseEthLog(rmap) elog, err := ParseEthLog(rmap)
@ -1983,7 +1971,6 @@ func parseEthLogsFromSubscriptionResponses(subResponses []ethtypes.EthSubscripti
} }
elogs = append(elogs, elog) elogs = append(elogs, elog)
} }
}
return elogs, nil return elogs, nil
} }