#1092 fix(mpt): treat as null if EmptyRootHash came as root (Port 9c-main → main)

Closed Lee Dogeon moreal
Coverage Reach
Libplanet.Tests/Net/SwarmTest.cs Libplanet.Tests/Net/SwarmTest.Preload.cs Libplanet.Tests/Net/Protocols/ProtocolTest.cs Libplanet.Tests/Net/Protocols/TestTransport.cs Libplanet.Tests/Net/Protocols/RoutingTableTest.cs Libplanet.Tests/Net/Protocols/TestMessage.cs Libplanet.Tests/Net/BlockCompletionTest.cs Libplanet.Tests/Net/Messages/RecentStatesTest.cs Libplanet.Tests/Net/Messages/BlockStatesTest.cs Libplanet.Tests/Net/Messages/MessageTest.cs Libplanet.Tests/Net/Messages/BlockHashesTest.cs Libplanet.Tests/Net/AppProtocolVersionTest.cs Libplanet.Tests/Net/SwarmTest.TrustedStateCompleter.cs Libplanet.Tests/Net/SwarmTest.AppProtocolVersion.cs Libplanet.Tests/Net/PeerTest.cs Libplanet.Tests/Net/SwarmTest.Fixtures.cs Libplanet.Tests/Net/FactOnlyTurnAvailableAttribute.cs Libplanet.Tests/Net/IceServerTest.cs Libplanet.Tests/Blockchain/BlockChainTest.cs Libplanet.Tests/Blockchain/Renderers/DelayedActionRendererTest.cs Libplanet.Tests/Blockchain/Renderers/LoggedActionRendererTest.cs Libplanet.Tests/Blockchain/Renderers/LoggedRendererTest.cs Libplanet.Tests/Blockchain/Renderers/AnonymousActionRendererTest.cs Libplanet.Tests/Blockchain/Renderers/DelayedRendererTest.cs Libplanet.Tests/Blockchain/Renderers/AnonymousRendererTest.cs Libplanet.Tests/Blockchain/Policies/BlockPolicyTest.cs Libplanet.Tests/Blockchain/BlockChainTest.ValidateNextBlock.cs Libplanet.Tests/Blockchain/BlockEvaluatorTest.cs Libplanet.Tests/Blockchain/BlockLocatorTest.cs Libplanet.Tests/Blockchain/NullPolicy.cs Libplanet.Tests/Store/StoreTest.cs Libplanet.Tests/Store/Trie/Nodes/NodeDecoderTest.cs Libplanet.Tests/Store/Trie/Nodes/ValueNodeTest.cs Libplanet.Tests/Store/Trie/Nodes/ShortNodeTest.cs Libplanet.Tests/Store/Trie/Nodes/FullNodeTest.cs Libplanet.Tests/Store/Trie/Nodes/HashNodeTest.cs Libplanet.Tests/Store/Trie/TrieTest.cs Libplanet.Tests/Store/Trie/KeyValueStoreTest.cs Libplanet.Tests/Store/Trie/MerkleTrieExtensionsTest.cs Libplanet.Tests/Store/Trie/MerkleTrieTest.cs Libplanet.Tests/Store/Trie/MemoryKeyValueStore.cs Libplanet.Tests/Store/Trie/BytesEqualityComparer.cs Libplanet.Tests/Store/Trie/CacheableKeyValueStoreTest.cs Libplanet.Tests/Store/Trie/DefaultKeyValueStoreTest.cs Libplanet.Tests/Store/StoreTracker.cs Libplanet.Tests/Store/StoreFixture.cs Libplanet.Tests/Store/TrieStateStoreTest.cs Libplanet.Tests/Store/BlockSetTest.cs Libplanet.Tests/Store/TransactionSetTest.cs Libplanet.Tests/Store/DefaultStoreTest.cs Libplanet.Tests/Store/DefaultStoreFixture.cs Libplanet.Tests/Store/StateStoreTrackerTest.cs Libplanet.Tests/Store/StoreTrackerTest.cs Libplanet.Tests/Store/StateStoreTracker.cs Libplanet.Tests/Store/StoreTrackLog.cs Libplanet.Tests/Store/BaseTracker.cs Libplanet.Tests/KeyStore/ProtectedPrivateKeyTest.cs Libplanet.Tests/KeyStore/Kdfs/ScryptTest.cs Libplanet.Tests/KeyStore/Kdfs/Pbkdf2Test.cs Libplanet.Tests/KeyStore/Kdfs/KdfTest.cs Libplanet.Tests/KeyStore/Ciphers/Aes128CtrTest.cs Libplanet.Tests/KeyStore/Ciphers/CipherTest.cs Libplanet.Tests/KeyStore/KeyStoreTest.cs Libplanet.Tests/KeyStore/Web3KeyStoreTest.cs Libplanet.Tests/KeyStore/IncorrectPassphraseExceptionTest.cs Libplanet.Tests/KeyStore/MismatchedAddressExceptionTest.cs Libplanet.Tests/Tx/TransactionTest.cs Libplanet.Tests/Tx/TxIdTest.cs Libplanet.Tests/Tx/TxFixture.cs Libplanet.Tests/Blocks/BlockTest.cs Libplanet.Tests/Blocks/BlockHeaderTest.cs Libplanet.Tests/Blocks/BlockFixture.cs Libplanet.Tests/Blocks/InvalidBlockBytesLengthExceptionTest.cs Libplanet.Tests/Common/Action/DumbAction.cs Libplanet.Tests/Common/Action/BattleResult.cs Libplanet.Tests/Common/Action/Attack.cs Libplanet.Tests/Common/Action/MinerReward.cs Libplanet.Tests/Common/Action/ThrowException.cs Libplanet.Tests/Common/Action/RandomAction.cs Libplanet.Tests/Common/Action/DetectRehearsal.cs Libplanet.Tests/Common/Action/Sleep.cs Libplanet.Tests/Common/Action/ExecuteRecord.cs Libplanet.Tests/Common/ValidatingActionRenderer.cs Libplanet.Tests/Common/RecordingRenderer.cs Libplanet.Tests/Common/RenderRecord.cs Libplanet.Tests/Action/AccountStateDeltaImplTest.cs Libplanet.Tests/Action/ActionContextTest.cs Libplanet.Tests/Action/PolymorphicActionTest.cs Libplanet.Tests/Action/UnexpectedlyTerminatedActionExceptionTest.cs Libplanet.Tests/Action/ActionEvaluationTest.cs Libplanet.Tests/Action/InsufficientBalanceExceptionTest.cs Libplanet.Tests/Action/ActionEvaluationExtensions.cs Libplanet.Tests/Action/ActionTypeAttributeTest.cs Libplanet.Tests/Assets/FungibleAssetValueTest.cs Libplanet.Tests/Assets/CurrencyTest.cs Libplanet.Tests/Crypto/PrivateKeyTest.cs Libplanet.Tests/Crypto/PublicKeyTest.cs Libplanet.Tests/Crypto/SymmetricKeyTest.cs Libplanet.Tests/TestUtils.cs Libplanet.Tests/AddressTest.cs Libplanet.Tests/HashDigestTest.cs Libplanet.Tests/HashcashTest.cs Libplanet.Tests/LoggerExtensions.cs Libplanet.Tests/ByteUtilTest.cs Libplanet.Tests/NonceTest.cs Libplanet.Tests/ByteArrayExtensionsTest.cs Libplanet.Tests/AddressExtensionsTest.cs Libplanet.Tests/ImmutableArrayEqualityComparer.cs Libplanet.Tests/RandomExtensions.cs Libplanet.Tests/HashSetExtensions.cs Libplanet.Tests/ActionProgress.cs Libplanet/Net/Swarm.cs Libplanet/Net/NetMQTransport.cs Libplanet/Net/Protocols/KademliaProtocol.cs Libplanet/Net/Protocols/RoutingTable.cs Libplanet/Net/Protocols/KBucket.cs Libplanet/Net/Protocols/Kademlia.cs Libplanet/Net/Protocols/PingTimeoutException.cs Libplanet/Net/Protocols/PeerDiscoveryException.cs Libplanet/Net/Messages/RecentStates.cs Libplanet/Net/Messages/Message.cs Libplanet/Net/Messages/BlockStates.cs Libplanet/Net/Messages/BlockHashes.cs Libplanet/Net/Messages/GetBlocks.cs Libplanet/Net/Messages/GetBlockHashes.cs Libplanet/Net/Messages/GetRecentStates.cs Libplanet/Net/Messages/Blocks.cs Libplanet/Net/Messages/TxIds.cs Libplanet/Net/Messages/ChainStatus.cs Libplanet/Net/Messages/GetTxs.cs Libplanet/Net/Messages/Neighbors.cs Libplanet/Net/Messages/BlockHeaderMessage.cs Libplanet/Net/Messages/Tx.cs Libplanet/Net/Messages/FindNeighbors.cs Libplanet/Net/Messages/GetBlockStates.cs Libplanet/Net/Messages/DifferentVersion.cs Libplanet/Net/Messages/GetChainStatus.cs Libplanet/Net/Messages/Pong.cs Libplanet/Net/Messages/Ping.cs Libplanet/Net/BlockCompletion.cs Libplanet/Net/Swarm.MessageHandlers.cs Libplanet/Net/AppProtocolVersion.cs Libplanet/Net/Swarm.TrustedStateCompleter.cs Libplanet/Net/NetMQSocketExtensions.cs Libplanet/Net/IceServer.cs Libplanet/Net/Peer.cs Libplanet/Net/BoundPeer.cs Libplanet/Net/InvalidMessageException.cs Libplanet/Net/NetMQFrameExtensions.cs Libplanet/Net/DifferentAppProtocolVersionException.cs Libplanet/Net/SwarmException.cs Libplanet/Net/PeerState.cs Libplanet/Net/PeerNotFoundException.cs Libplanet/Net/InvalidStateTargetException.cs Libplanet/Net/NoSwarmContextException.cs Libplanet/Net/PeerChainState.cs Libplanet/Net/SwarmOptions.cs Libplanet/Net/BlockDownloadState.cs Libplanet/Net/BlockHashDemand.cs Libplanet/Net/BlockVerificationState.cs Libplanet/Net/BlockHashDownloadState.cs Libplanet/Net/ActionExecutionState.cs Libplanet/Net/IceServerException.cs Libplanet/Net/StateDownloadState.cs Libplanet/Blockchain/BlockChain.cs Libplanet/Blockchain/Renderers/DelayedActionRenderer.cs Libplanet/Blockchain/Renderers/DelayedRenderer.cs Libplanet/Blockchain/Renderers/LoggedRenderer.cs Libplanet/Blockchain/Renderers/LoggedActionRenderer.cs Libplanet/Blockchain/Renderers/AnonymousActionRenderer.cs Libplanet/Blockchain/Renderers/AnonymousRenderer.cs Libplanet/Blockchain/BlockEvaluator.cs Libplanet/Blockchain/Policies/BlockPolicy.cs Libplanet/Blockchain/BlockLocator.cs Libplanet/Blockchain/FungibleAssetStateCompleters.cs Libplanet/Blockchain/StateCompleterSet.cs Libplanet/Blockchain/IncompleteBlockStatesException.cs Libplanet/Blockchain/StateCompleters.cs Libplanet/Blockchain/MineBlockEventArgs.cs Libplanet/Blockchain/KeyConverters.cs Libplanet/Store/DefaultStore.cs Libplanet/Store/Trie/MerkleTrie.cs Libplanet/Store/Trie/Nodes/NodeDecoder.cs Libplanet/Store/Trie/Nodes/FullNode.cs Libplanet/Store/Trie/Nodes/ShortNode.cs Libplanet/Store/Trie/Nodes/ValueNode.cs Libplanet/Store/Trie/Nodes/HashNode.cs Libplanet/Store/Trie/Nodes/BaseNode.cs Libplanet/Store/Trie/Nodes/INodeExtensions.cs Libplanet/Store/Trie/DefaultKeyValueStore.cs Libplanet/Store/Trie/MerkleTrieExtensions.cs Libplanet/Store/Trie/CacheableKeyValueStore.cs Libplanet/Store/Trie/ITrieExtensions.cs Libplanet/Store/Trie/InvalidTrieNodeException.cs Libplanet/Store/TrieStateStore.cs Libplanet/Store/StoreExtensions.cs Libplanet/Store/BlockSet.cs Libplanet/Store/BaseIndex.cs Libplanet/Store/TransactionSet.cs Libplanet/Store/BaseStore.cs Libplanet/Store/BaseBlockStatesStore.cs Libplanet/Store/ChainIdNotFoundException.cs Libplanet/KeyStore/Kdfs/Scrypt.cs Libplanet/KeyStore/Kdfs/Pbkdf2.cs Libplanet/KeyStore/ProtectedPrivateKey.cs Libplanet/KeyStore/Web3KeyStore.cs Libplanet/KeyStore/Ciphers/Aes128Ctr.cs Libplanet/KeyStore/IncorrectPassphraseException.cs Libplanet/KeyStore/MismatchedAddressException.cs Libplanet/KeyStore/NoKeyException.cs Libplanet/KeyStore/KeyStoreException.cs Libplanet/KeyStore/InvalidKeyJsonException.cs Libplanet/KeyStore/KeyJsonException.cs Libplanet/KeyStore/UnsupportedKeyJsonException.cs Libplanet/Blocks/Block.cs Libplanet/Blocks/BlockHeader.cs Libplanet/Blocks/BlockDigest.cs Libplanet/Blocks/RawBlock.cs Libplanet/Blocks/InvalidBlockBytesLengthException.cs Libplanet/Blocks/InvalidBlockStateRootHashException.cs Libplanet/Blocks/InvalidGenesisBlockException.cs Libplanet/Blocks/InvalidBlockTotalDifficultyException.cs Libplanet/Blocks/InvalidBlockException.cs Libplanet/Blocks/InvalidBlockPreviousHashException.cs Libplanet/Blocks/InvalidBlockDifficultyException.cs Libplanet/Blocks/InvalidBlockTimestampException.cs Libplanet/Blocks/InvalidBlockNonceException.cs Libplanet/Blocks/InvalidBlockIndexException.cs Libplanet/Blocks/InvalidBlockHashException.cs Libplanet/Tx/Transaction.cs Libplanet/Tx/RawTransaction.cs Libplanet/Tx/TxId.cs Libplanet/Tx/InvalidTxUpdatedAddressesException.cs Libplanet/Tx/InvalidTxGenesisHashException.cs Libplanet/Tx/InvalidTxNonceException.cs Libplanet/Tx/InvalidTxException.cs Libplanet/Tx/InvalidTxIdException.cs Libplanet/Tx/TxViolatingBlockPolicyException.cs Libplanet/Tx/InvalidTxSignatureException.cs Libplanet/Tx/InvalidTxPublicKeyException.cs Libplanet/Action/AccountStateDeltaImpl.cs Libplanet/Action/ActionEvaluation.cs Libplanet/Action/UnexpectedlyTerminatedActionException.cs Libplanet/Action/PolymorphicAction.cs Libplanet/Action/ActionContext.cs Libplanet/Action/ActionEvaluationsExtensions.cs Libplanet/Action/IAccountStateDeltaExtensions.cs Libplanet/Action/InsufficientBalanceException.cs Libplanet/Action/ActionTypeAttribute.cs Libplanet/Action/CurrencyPermissionException.cs Libplanet/Action/RandomExtensions.cs Libplanet/Action/MissingActionTypeException.cs Libplanet/Action/Random.cs Libplanet/Crypto/PrivateKey.cs Libplanet/Crypto/SymmetricKey.cs Libplanet/Crypto/PublicKey.cs Libplanet/Crypto/DefaultCryptoBackend.cs Libplanet/Crypto/InvalidCiphertextException.cs Libplanet/Crypto/CryptoConfig.cs Libplanet/Assets/FungibleAssetValue.cs Libplanet/Assets/Currency.cs Libplanet/Address.cs Libplanet/HashDigest.cs Libplanet/ByteUtil.cs Libplanet/Hashcash.cs Libplanet/ByteArrayExtensions.cs Libplanet/Nonce.cs Libplanet/FixedSizedQueue.cs Libplanet/Serialization/SerializationInfoExtensions.cs Libplanet/AddressExtensions.cs Libplanet.Stun/Stun/Messages/StunMessage.cs Libplanet.Stun/Stun/Messages/AllocateErrorResponse.cs Libplanet.Stun/Stun/Messages/AllocateRequest.cs Libplanet.Stun/Stun/Messages/RefreshErrorResponse.cs Libplanet.Stun/Stun/Messages/RefreshRequest.cs Libplanet.Stun/Stun/Messages/ConnectRequest.cs Libplanet.Stun/Stun/Messages/CreatePermissionRequest.cs Libplanet.Stun/Stun/Messages/ConnectionBindRequest.cs Libplanet.Stun/Stun/Messages/BindingRequest.cs Libplanet.Stun/Stun/Messages/BindingSuccessResponse.cs Libplanet.Stun/Stun/Messages/AllocateSuccessResponse.cs Libplanet.Stun/Stun/Messages/ConnectionAttempt.cs Libplanet.Stun/Stun/Messages/RefreshSuccessResponse.cs Libplanet.Stun/Stun/Messages/ConnectSuccessResponse.cs Libplanet.Stun/Stun/Messages/CreatePermissionErrorResponse.cs Libplanet.Stun/Stun/Messages/CreatePermissionSuccessResponse.cs Libplanet.Stun/Stun/Messages/ConnectionBindSuccessResponse.cs Libplanet.Stun/Stun/Attributes/StunAddressExtensions.cs Libplanet.Stun/Stun/Attributes/ErrorCode.cs Libplanet.Stun/Stun/Attributes/MessageIntegrity.cs Libplanet.Stun/Stun/Attributes/Fingerprint.cs Libplanet.Stun/Stun/Attributes/XorPeerAddress.cs Libplanet.Stun/Stun/Attributes/XorMappedAddress.cs Libplanet.Stun/Stun/Attributes/XorRelayedAddress.cs Libplanet.Stun/Stun/Attributes/Nonce.cs Libplanet.Stun/Stun/Attributes/Realm.cs Libplanet.Stun/Stun/Attributes/Attribute.cs Libplanet.Stun/Stun/Attributes/Software.cs Libplanet.Stun/Stun/Attributes/Lifetime.cs Libplanet.Stun/Stun/Attributes/ConnectionId.cs Libplanet.Stun/Stun/Attributes/RequestedTransport.cs Libplanet.Stun/Stun/Attributes/Username.cs Libplanet.Stun/Stun/Attributes/InvalidStunAddressException.cs Libplanet.Stun/Stun/TurnClient.cs Libplanet.Stun/Stun/BytesConvertExtensions.cs Libplanet.Stun/Stun/Crc32.cs Libplanet.Stun/Stun/TurnClientException.cs Libplanet.RocksDBStore/RocksDBStore.cs Libplanet.RocksDBStore/RocksDBKeyValueStore.cs Libplanet.RocksDBStore/RocksDBStoreBitConverter.cs Libplanet.RocksDBStore/RocksDBUtils.cs Libplanet.Stun.Tests/Stun/Messages/StunMessageTest.cs Libplanet.Stun.Tests/Stun/Messages/AllocateRequestTest.cs Libplanet.Stun.Tests/Stun/Messages/CreatePermissionRequestTest.cs Libplanet.Stun.Tests/Stun/Messages/ConnectionBindRequestTest.cs Libplanet.Stun.Tests/Stun/Messages/AllocateErrorResponseTest.cs Libplanet.Stun.Tests/Stun/Messages/AllocateSuccessResponseTest.cs Libplanet.Stun.Tests/Stun/Messages/RefreshSuccessResponseTest.cs Libplanet.Stun.Tests/Stun/Messages/RefreshErrorResponseTest.cs Libplanet.Stun.Tests/Stun/Messages/ConnectionBindSuccessResponseTest.cs Libplanet.Stun.Tests/Stun/Messages/CreatePermissionSuccessResponseTest.cs Libplanet.Stun.Tests/Stun/Messages/ConnectionAttemptTest.cs Libplanet.Stun.Tests/Stun/Messages/RefreshRequestTest.cs Libplanet.Stun.Tests/Stun/Messages/BindingRequestTest.cs Libplanet.Stun.Tests/Stun/Messages/BindingRequestSucessTest.cs Libplanet.Stun.Tests/Stun/Messages/TestStunContext.cs Libplanet.Stun.Tests/Stun/Attributes/MessageIntegrityTest.cs Libplanet.Stun.Tests/Stun/Attributes/StunAddressExtensionsTest.cs Libplanet.Stun.Tests/Stun/Attributes/NonceTest.cs Libplanet.Stun.Tests/Stun/Attributes/ErrorCodeTest.cs Libplanet.Stun.Tests/Stun/Attributes/RealmTest.cs Libplanet.Stun.Tests/Stun/Attributes/UserNameTest.cs Libplanet.Stun.Tests/Stun/Attributes/RequestedTransportTest.cs Libplanet.Stun.Tests/Stun/Attributes/LifetimeTest.cs Libplanet.Stun.Tests/Stun/Crc32Test.cs Libplanet.Analyzers.Tests/Verifiers/DiagnosticVerifier.cs Libplanet.Analyzers.Tests/Verifiers/DiagnosticVerifier.Helper.cs Libplanet.Analyzers.Tests/ActionAnalyzerTest.cs Libplanet.Analyzers.Tests/Helpers/DiagnosticResultLocation.cs Libplanet.Analyzers.Tests/Helpers/DiagnosticResult.cs Libplanet.Analyzers/ActionAnalyzer.cs Libplanet.RocksDBStore.Tests/RocksDBStoreTest.cs Libplanet.RocksDBStore.Tests/RocksDBStoreFixture.cs Libplanet.RocksDBStore.Tests/RocksDBKeyValueStoreTest.cs

No flags found

Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.

e.g., #unittest #integration

#production #enterprise

#frontend #backend

Learn more about Codecov Flags here.


@@ -16,6 +16,10 @@
Loading
16 16
                = new HashDigest<SHA256>(TestUtils.GetRandomBytes(HashDigest<SHA256>.Size));
17 17
            var merkleTrie = new MerkleTrie(new MemoryKeyValueStore(), hashDigest);
18 18
            Assert.Equal(hashDigest, merkleTrie.Hash);
19 +
20 +
            // See https://github.com/planetarium/libplanet/pull/1091
21 +
            merkleTrie = new MerkleTrie(new MemoryKeyValueStore(), MerkleTrie.EmptyRootHash);
22 +
            Assert.Null(merkleTrie.Root);
19 23
        }
20 24
21 25
        [Fact]

@@ -63,13 +63,15 @@
Loading
63 63
        internal MerkleTrie(IKeyValueStore keyValueStore, INode? root = null, bool secure = false)
64 64
        {
65 65
            KeyValueStore = keyValueStore;
66 -
            Root = root;
66 +
            Root = root is HashNode hashNode && hashNode.HashDigest.Equals(EmptyRootHash)
67 +
                ? null
68 +
                : root;
67 69
            _secure = secure;
68 70
        }
69 71
70 72
        public HashDigest<SHA256> Hash => Root?.Hash() ?? EmptyRootHash;
71 73
72 -
        private INode? Root { get; }
74 +
        internal INode? Root { get; }
73 75
74 76
        private IKeyValueStore KeyValueStore { get; }
75 77

Learn more Showing 4 files with coverage changes found.

Changes in Libplanet.Tests/Net/SwarmTest.Preload.cs
-2
+2
Loading file...
Changes in Libplanet.RocksDBStore/RocksDBStore.cs
-2
+2
Loading file...
Changes in Libplanet/Net/Protocols/KademliaProtocol.cs
-2
+2
Loading file...
Changes in Libplanet/Net/Swarm.cs
-1
-15
+16
Loading file...
Files Coverage
Libplanet 0.16% 86.61%
Libplanet.Analyzers.Tests 84.07%
Libplanet.RocksDBStore 0.29% 95.77%
Libplanet.RocksDBStore.Tests 77.46%
Libplanet.Stun.Tests/Stun 99.56%
Libplanet.Stun/Stun 77.88%
Libplanet.Tests 0.01% 89.52%
Libplanet.Analyzers/ActionAnalyzer.cs 82.58%
Project Totals (344 files) 88.35%
Loading