core: make test chain format compatible with mainnet

Write uint32 length before every block.
This commit is contained in:
Evgenii Stratonikov 2020-02-26 17:51:30 +03:00
parent 51c4868641
commit 44792ed5f7
3 changed files with 2 additions and 0 deletions

View file

@ -275,6 +275,7 @@ func _(t *testing.T) {
buf := io.NewBufBinWriter()
b.EncodeBinary(buf.BinWriter)
bytes := buf.Bytes()
writer.WriteU32LE(uint32(len(bytes)))
writer.WriteBytes(bytes)
require.NoError(t, writer.Err)
}

View file

@ -52,6 +52,7 @@ func initServerWithInMemoryChain(t *testing.T) (*core.Blockchain, http.HandlerFu
nBlocks = br.ReadU32LE()
require.Nil(t, br.Err)
for i := 0; i < int(nBlocks); i++ {
_ = br.ReadU32LE()
b := &block.Block{}
b.DecodeBinary(br)
require.Nil(t, br.Err)

Binary file not shown.