MCPcopy Create free account
hub / github.com/base/triedb / test_storage_leaf_node_serialize

Function test_storage_leaf_node_serialize

src/node.rs:815–854  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

813
814 #[test]
815 fn test_storage_leaf_node_serialize() {
816 let node = Node::new_leaf(
817 &RawPath::from_nibbles(&[0xa, 0xb]),
818 &TrieValue::Storage(StorageValue::from_be_slice(&[4, 5, 6])),
819 )
820 .expect("can create node");
821 let bytes = node.serialize().unwrap();
822 assert_eq!(bytes, hex!("0x0002ab83040506"));
823
824 let node = Node::new_leaf(
825 &RawPath::from_nibbles(&[0xa, 0xb, 0xc]),
826 &TrieValue::Storage(StorageValue::from_be_slice(&[4, 5, 6, 7])),
827 )
828 .expect("can create node");
829 let bytes = node.serialize().unwrap();
830 assert_eq!(bytes, hex!("0x0003abc08404050607"));
831
832 let node = Node::new_leaf(
833 &RawPath::new(),
834 &TrieValue::Storage(StorageValue::from_be_slice(&[255, 255, 255, 255])),
835 )
836 .expect("can create node");
837 let bytes = node.serialize().unwrap();
838 assert_eq!(bytes, hex!("0x000084ffffffff"));
839
840 let node = Node::new_leaf(&RawPath::new(), &TrieValue::Storage(StorageValue::from(0)))
841 .expect("can create node");
842 let bytes = node.serialize().unwrap();
843 assert_eq!(bytes, hex!("0x000080"));
844
845 let node = Node::new_leaf(
846 &RawPath::from_nibbles(&hex!(
847 "0x000102030405060708090a0b0c0d0e0f000102030405060708090a0b0c0d0e0f"
848 )),
849 &TrieValue::Storage(StorageValue::from(U256::MAX)),
850 )
851 .expect("can create node");
852 let bytes = node.serialize().unwrap();
853 assert_eq!(bytes, hex!("0x00200123456789abcdef0123456789abcdefa0ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"));
854 }
855
856 #[test]
857 fn test_account_leaf_node_serialize() {

Callers

nothing calls this directly

Calls 1

serializeMethod · 0.80

Tested by

no test coverage detected