github.com/status-im/status-go@v1.1.0/waku/v0/message_response_test.go (about) 1 // Copyright 2019 The Waku Library Authors. 2 // 3 // The Waku library is free software: you can redistribute it and/or modify 4 // it under the terms of the GNU Lesser General Public License as published by 5 // the Free Software Foundation, either version 3 of the License, or 6 // (at your option) any later version. 7 // 8 // The Waku library is distributed in the hope that it will be useful, 9 // but WITHOUT ANY WARRANTY; without even the implied warranty off 10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 // GNU Lesser General Public License for more details. 12 // 13 // You should have received a copy of the GNU Lesser General Public License 14 // along with the Waku library. If not, see <http://www.gnu.org/licenses/>. 15 // 16 // This software uses the go-ethereum library, which is licensed 17 // under the GNU Lesser General Public Library, version 3 or any later. 18 19 package v0 20 21 import ( 22 "testing" 23 24 "github.com/stretchr/testify/require" 25 26 gethcommon "github.com/ethereum/go-ethereum/common" 27 "github.com/ethereum/go-ethereum/rlp" 28 29 "github.com/status-im/status-go/waku/common" 30 ) 31 32 func TestEncodeDecodeVersionedResponse(t *testing.T) { 33 response := NewMessagesResponse(gethcommon.Hash{1}, []common.EnvelopeError{{Code: 1}}) 34 bytes, err := rlp.EncodeToBytes(response) 35 require.NoError(t, err) 36 37 var mresponse MultiVersionResponse 38 require.NoError(t, rlp.DecodeBytes(bytes, &mresponse)) 39 v1resp, err := mresponse.DecodeResponse1() 40 require.NoError(t, err) 41 require.Equal(t, response.Response.Hash, v1resp.Hash) 42 }