From 85d059b7ae8b31da26d710666db4a82623b01daf Mon Sep 17 00:00:00 2001 From: Matthieu Vachon Date: Tue, 5 May 2020 22:29:15 -0400 Subject: [PATCH] Fixed `BlockState` `ConfirmedCount` not of the right type, should have been a `[]uint8` --- CHANGELOG.md | 5 +++-- decoder_test.go | 6 ++++-- p2ptypes.go | 2 +- testdata/block_state_1.hex | 1 + 4 files changed, 9 insertions(+), 5 deletions(-) create mode 100644 testdata/block_state_1.hex diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c7d5e62..eae55cb6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,8 +6,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Added -- `TimePoint` will decode with `0` nanoseconds, when the `fitNodeos` flag is set on the ABI. -- Ability to decode a `int128` and `uint128` in decimal format when `fitNodeos` flag is set on the ABI +- `TimePoint` will decode with `0` nanoseconds, when the `fitNodeos` flag is set on the ABI. +- Ability to decode a `int128` and `uint128` in decimal format when `fitNodeos` flag is set on the ABI - Ability to decode nested `arrays` in ABI decoder. - Added `BlockState.Header` field of type `SignedBlockHeader` that was previously missing from the struct definition. - Added `BlockState.AdditionalSignatures` field of type `[]ecc.Signature` that was previously missing from the struct definition. @@ -29,6 +29,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `BlockState.ProducerToLastImpliedIRB` is now `[]PairAccountNameBlockNum`, was previously `[][2]EOSNameOrUint32`. - `BlockState.BlockID` is now a `Checksum256`, was previously `string`. - `BlockState.ActivatedProtocolFeatures` is now a `*ProtocolFeatureActivationSet`, was previously `map[string][]HexBytes`. + - `BlockState.ConfirmCount` is now a `[]uint8`, was previously `[]uint32`. - `PendingSchedule.ScheduleHash` is now a `Checksum256`, was previously `HexBytes`. - `ActionTraceReceipt.ActionDigest` is now a `Checksum256`, was previously `string`. - `ActionTraceReceipt.CodeSequence` is now a `Varuint32`, was previously `Uint64`. diff --git a/decoder_test.go b/decoder_test.go index 2fc77849..996f409a 100644 --- a/decoder_test.go +++ b/decoder_test.go @@ -369,8 +369,10 @@ func TestDecoder_Empty_Signature(t *testing.T) { } func TestDecoder_BlockState(t *testing.T) { - hexString := "12000000120000001100000000000000010000000000ea305500010000000100023cd6a339e452311cb809c71d6652f67c388579004128aee87f623d201e61170e0100030000001104f2e04ac6caf545add296c46d6adfac2ac96190fe4b04f8bbec6a525f62ff1fce4412629c25e9eed6c7a235202f6666c1062e62559af5b0d9442d6a6f1ab6bd9ace48d4a174bf44582d64e738c7cc9f94573628f023c9791be418751100000000000000010000000000ea305512000000010000000000ea30551100000000010000000100023cd6a339e452311cb809c71d6652f67c388579004128aee87f623d201e61170e01000000000012b518a7d08697f9b5a3899d549d0393331c83a91af5c3ab362254c174fd34864b0000000000ea305500000000001104f2e04ac6caf545add296c46d6adfac2ac96190fe4b04f8bbec6a529070367f85cb9bf5144da126a59b13822df98aec0b8df5b41d9117d04f871dc52b09133824ea7518fedfd10cbebe38a79c0bc1f2752ca0d2e93319c88813f999000000000000001f2815130a419a1ecc5ea3a98ee00b5482f6b908c2dd40d6a7fb3801e6d8a5a08d1436cd98f2ebdb642c987a59e2d4fe1a32427b39bd504f145dc853bc9f0a6a90000000002f74e78d3382fdadcbbdb7b111ca91efeea4109d59ac94945951fca6c498aef6000000000001000001fd34864b0000000000ea305500000000001104f2e04ac6caf545add296c46d6adfac2ac96190fe4b04f8bbec6a529070367f85cb9bf5144da126a59b13822df98aec0b8df5b41d9117d04f871dc52b09133824ea7518fedfd10cbebe38a79c0bc1f2752ca0d2e93319c88813f999000000000000001f2815130a419a1ecc5ea3a98ee00b5482f6b908c2dd40d6a7fb3801e6d8a5a08d1436cd98f2ebdb642c987a59e2d4fe1a32427b39bd504f145dc853bc9f0a6a900100e94300002a01010020198466d49ea8763e341f3c5a9ae22b26386049cbc997347ed0bc2eb2b8e2dba51740ff906baf06f620df575b51ab2c72fad0c979a4a967b8b0abc8e3c51630250000a1021b5e305e1000dc1f790300000000030000000000ea305500409e9a2264b89a011052546ea998b33900000000a8ed3232661052546ea998b3392052546ea998b339010000000100023cd6a339e452311cb809c71d6652f67c388579004128aee87f623d201e61170e01000000010000000100023cd6a339e452311cb809c71d6652f67c388579004128aee87f623d201e61170e010000000000000000ea305500003f2a1ba6a24a011052546ea998b33900000000a8ed3232311052546ea998b3392052546ea998b339102700000000000004454f5300000000102700000000000004454f5300000000010000000000ea305500b0cafe4873bd3e011052546ea998b33900000000a8ed3232141052546ea998b3392052546ea998b33900200000000000" - rawData, err := hex.DecodeString(hexString) + hexString, err := ioutil.ReadFile("testdata/block_state_1.hex") + require.NoError(t, err) + + rawData, err := hex.DecodeString(string(hexString)) require.NoError(t, err) decoder := NewDecoder(rawData) diff --git a/p2ptypes.go b/p2ptypes.go index 397f9479..7ba5f9c0 100644 --- a/p2ptypes.go +++ b/p2ptypes.go @@ -290,7 +290,7 @@ type BlockState struct { // EOSIO 2.x ValidBlockSigningAuthorityV2 *BlockSigningAuthority `json:"valid_block_signing_authority,omitempty"` - ConfirmCount []uint32 `json:"confirm_count,omitempty"` + ConfirmCount []uint8 `json:"confirm_count,omitempty"` BlockID Checksum256 `json:"id"` Header *SignedBlockHeader `json:"header,omitempty"` diff --git a/testdata/block_state_1.hex b/testdata/block_state_1.hex new file mode 100644 index 00000000..e38d605b --- /dev/null +++ b/testdata/block_state_1.hex @@ -0,0 +1 @@ +12000000120000001100000000000000010000000000ea305500010000000100023cd6a339e452311cb809c71d6652f67c388579004128aee87f623d201e61170e0100030000001104f2e04ac6caf545add296c46d6adfac2ac96190fe4b04f8bbec6a525f62ff1fce4412629c25e9eed6c7a235202f6666c1062e62559af5b0d9442d6a6f1ab6bd9ace48d4a174bf44582d64e738c7cc9f94573628f023c9791be418751100000000000000010000000000ea305512000000010000000000ea30551100000000010000000100023cd6a339e452311cb809c71d6652f67c388579004128aee87f623d201e61170e01000000000012b518a7d08697f9b5a3899d549d0393331c83a91af5c3ab362254c174fd34864b0000000000ea305500000000001104f2e04ac6caf545add296c46d6adfac2ac96190fe4b04f8bbec6a529070367f85cb9bf5144da126a59b13822df98aec0b8df5b41d9117d04f871dc52b09133824ea7518fedfd10cbebe38a79c0bc1f2752ca0d2e93319c88813f999000000000000001f2815130a419a1ecc5ea3a98ee00b5482f6b908c2dd40d6a7fb3801e6d8a5a08d1436cd98f2ebdb642c987a59e2d4fe1a32427b39bd504f145dc853bc9f0a6a90000000002f74e78d3382fdadcbbdb7b111ca91efeea4109d59ac94945951fca6c498aef6000000000001000001fd34864b0000000000ea305500000000001104f2e04ac6caf545add296c46d6adfac2ac96190fe4b04f8bbec6a529070367f85cb9bf5144da126a59b13822df98aec0b8df5b41d9117d04f871dc52b09133824ea7518fedfd10cbebe38a79c0bc1f2752ca0d2e93319c88813f999000000000000001f2815130a419a1ecc5ea3a98ee00b5482f6b908c2dd40d6a7fb3801e6d8a5a08d1436cd98f2ebdb642c987a59e2d4fe1a32427b39bd504f145dc853bc9f0a6a900100e94300002a01010020198466d49ea8763e341f3c5a9ae22b26386049cbc997347ed0bc2eb2b8e2dba51740ff906baf06f620df575b51ab2c72fad0c979a4a967b8b0abc8e3c51630250000a1021b5e305e1000dc1f790300000000030000000000ea305500409e9a2264b89a011052546ea998b33900000000a8ed3232661052546ea998b3392052546ea998b339010000000100023cd6a339e452311cb809c71d6652f67c388579004128aee87f623d201e61170e01000000010000000100023cd6a339e452311cb809c71d6652f67c388579004128aee87f623d201e61170e010000000000000000ea305500003f2a1ba6a24a011052546ea998b33900000000a8ed3232311052546ea998b3392052546ea998b339102700000000000004454f5300000000102700000000000004454f5300000000010000000000ea305500b0cafe4873bd3e011052546ea998b33900000000a8ed3232141052546ea998b3392052546ea998b33900200000000000 \ No newline at end of file