consensus: update binary test data
This commit is contained in:
parent
04bff62d65
commit
7eadbcb062
2 changed files with 32 additions and 7 deletions
|
@ -2,6 +2,7 @@ package consensus
|
|||
|
||||
import (
|
||||
"encoding/hex"
|
||||
gio "io"
|
||||
"math/rand"
|
||||
"testing"
|
||||
|
||||
|
@ -321,3 +322,20 @@ func TestMessageType_String(t *testing.T) {
|
|||
require.Equal(t, "RecoveryRequest", recoveryRequestType.String())
|
||||
require.Equal(t, "UNKNOWN(0xff)", messageType(0xff).String())
|
||||
}
|
||||
|
||||
func TestPayload_DecodeFromTestnet(t *testing.T) {
|
||||
hexDump := "000000005e3c788da53e6669772c408014abab20c9f33d1a38396de645a2d40fb3a8a37c960801000400423000aaf1b1cd5544485412eab6b1af49b57ae83b236595a0918488a9899e540c4e105aee59ed2cef1015f205ff1909312acab39d504d68f141c77e10ae21e14971ce01420c4040cfd9a6d6aa245d79a905864551dcc68e108c40231b7df8178663ae453f62388c9bd6bf10b1f1fb1a8736faba5561a886efa78ea5ff4f98812a9d2adba5f1f5290c2102a7834be9b32e2981d157cb5bbd3acb42cfd11ea5c3b10224d7a44e98c5910f1b0b4195440d78"
|
||||
data, err := hex.DecodeString(hexDump)
|
||||
require.NoError(t, err)
|
||||
|
||||
buf := io.NewBinReaderFromBuf(data)
|
||||
p := NewPayload(netmode.TestNet)
|
||||
p.DecodeBinary(buf)
|
||||
require.NoError(t, buf.Err)
|
||||
require.NoError(t, p.decodeData())
|
||||
require.Equal(t, payload.CommitType, p.Type())
|
||||
require.Equal(t, uint32(67734), p.Height())
|
||||
|
||||
buf.ReadB()
|
||||
require.Equal(t, gio.EOF, buf.Err)
|
||||
}
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
package consensus
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
gio "io"
|
||||
"testing"
|
||||
|
||||
"github.com/nspcc-dev/dbft/crypto"
|
||||
"github.com/nspcc-dev/dbft/payload"
|
||||
"github.com/nspcc-dev/neo-go/pkg/config/netmode"
|
||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||
"github.com/nspcc-dev/neo-go/pkg/io"
|
||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
@ -114,23 +118,26 @@ func TestRecoveryMessage_Setters(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
//TODO NEO3.0: Update binary
|
||||
/*
|
||||
func TestRecoveryMessage_DecodeFromTestnet(t *testing.T) {
|
||||
hexDump := "00000000924b2fa6728782b6afb94873a377c49f31573005e7f2945beb27158ec2e887300d180000010000000000" +
|
||||
"fd29024100000120003db64b5e8e4ab7138abe65a3be48d3a3f5d10013ab9ffee489706078714f1ea20161e7ba952fdfd5f543891b1fe053af401bc34e9e3f63c90e3c0d6675d156344b00008e4ab71300000000030000414079946c76007e4297b06b074a20dc1d1d6871c74976f244df81bd03f4158a11dd485ed50fc0cc7c6ad352addd8440c5a55d7b7449650bb200e5e58b1fb8a0390c010041403631a490b17ca4fcfe52ed2e7a4ca4c0d3fcca67e73a1ef071f385db1d37cefa7a2de6e56654788647e9142425c29449b0bbfee5c46a96c4bdc79b23c1f862fc02004140147914878c23a9624a62598cebe2c75fdce80c1e19b5c73aa511630f67d4e5a660c63daad7fcfa9bd944f258f51427cb80730b8beb3015a3c2766325bf291a8e02000000989f8fa676ed07885a46ee08af10e1fa1893ef20fbd557dc3c1a9dc498189d5fceff694dcb2085e4969d90c56433b88fd7ba1caef9363829c70419a5314ac36541404f3ee34e11c521f2e31fee439206474d36951443014354ce81b32bd1787e6a92212737f7f72bee59c403ff74292ebf78c4091081174b5921c148cedcbe7bd585000100acfc8399bda6429c64b5c09885a3e4f1a0629f59125df03be956c00f5bb77616c43e43250e96700f80c42ef3e169e9ff9f906518acf0da17c53563ba41d91ebc41409957436afd1736970d4b5e52b8d845663d6b0335a34cf78ece733c71be876cf30125e9bfea197a607ea6945cef7ef28a74676ec23d14378f7ec23964544b6710014140b634941ecab3a5dd7251f9213bfbcff2021b1e3d966e6800007ea6f0d72ec46d2c04c042800e103091d2f5d184d997a10b890b13bf06b1078a4f1822d722891a232102a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd62ac"
|
||||
func TestRecoveryMessage_Decode(t *testing.T) {
|
||||
hexDump := "000000007f5b6094e1281e6bac667f1f871aee755dbe62c012868c718d7709de62135d250d1800000100fd0f024100000120003db64b5e000000008e4ab7138abe65a30133175ebcf3c66ad59ed2c532ca19bbb84cb3802f7dc9b6decde10e117ff6fc3303000041e52280e60c46778876e4c7fdcd262170d906090256ff2ac11d14d45516dd465b5b8f241ff78096ee7280f226df677681bff091884dcd7c4f25cd9a61856ce0bc6a01004136b0b971ef320135f61c11475ff07c5cad04635fc1dad41d346d085646e29e6ff1c5181421a203e5d4b627c6bacdd78a78c9f4cb0a749877ea5a9ed2b02196f17f020041ac5e279927ded591c234391078db55cad2ada58bded974fa2d2751470d0b2f94dddc84ed312f31ee960c884066f778e000f4f05883c74defa75d2a2eb524359c7d020000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000041546d2e34cbbfd0d09b7ce937eec07b402bd597f7bef24938f4a01041f443fb4dd31bebcabdaae3942bb9d549724a152e851bee43ebc5f482ddd9316f2690b48e7d00010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000415281a6579b875c480d9b3cc9144485d1f898e13405eaf1e4117d83844f1265f81a71998d53fa32d6c3b5249446ac036ecda73b1fe8c1341475fcc4b8d6ba8ec6e20141d775fd1a605173a8ed02084fef903ee043239ca4c76cb658809c6216031437e8f4d5a265550d5934fe386732364d9b49a14baef5a1236d02c557cb394a3a0873c82364f65259a991768a35ba18777f76901e1022f87d71910f4e3e46f161299401f2074d0c"
|
||||
data, err := hex.DecodeString(hexDump)
|
||||
require.NoError(t, err)
|
||||
|
||||
buf := io.NewBinReaderFromBuf(data)
|
||||
var p Payload
|
||||
p := NewPayload(netmode.TestNet)
|
||||
p.DecodeBinary(buf)
|
||||
require.NoError(t, buf.Err)
|
||||
require.NoError(t, p.decodeData())
|
||||
require.Equal(t, payload.RecoveryMessageType, p.Type())
|
||||
require.NotNil(t, p.message.payload)
|
||||
req := p.message.payload.(*recoveryMessage).prepareRequest
|
||||
require.NotNil(t, req)
|
||||
require.Equal(t, prepareRequestType, p.message.payload.(*recoveryMessage).prepareRequest.Type)
|
||||
|
||||
buf.ReadB()
|
||||
require.Equal(t, gio.EOF, buf.Err)
|
||||
}
|
||||
*/
|
||||
|
||||
func getKeys(t *testing.T, n int) []*privateKey {
|
||||
privs := make([]*privateKey, 0, n)
|
||||
for i := 0; i < n; i++ {
|
||||
|
|
Loading…
Reference in a new issue