| 758 | |
| 759 | #[test] |
| 760 | fn test_insert_static() { |
| 761 | let mut node = TrieNode::Empty; |
| 762 | let noop_fetcher = NoopTrieProvider; |
| 763 | node.insert(&Nibbles::unpack(hex!("012345")), bytes!("01"), &noop_fetcher).unwrap(); |
| 764 | node.insert(&Nibbles::unpack(hex!("012346")), bytes!("02"), &noop_fetcher).unwrap(); |
| 765 | |
| 766 | let expected = TrieNode::Extension { |
| 767 | prefix: Nibbles::from_nibbles([0, 1, 2, 3, 4]), |
| 768 | node: Box::new(TrieNode::Branch { |
| 769 | stack: vec![ |
| 770 | TrieNode::Empty, |
| 771 | TrieNode::Empty, |
| 772 | TrieNode::Empty, |
| 773 | TrieNode::Empty, |
| 774 | TrieNode::Empty, |
| 775 | TrieNode::Leaf { prefix: Nibbles::default(), value: bytes!("01") }, |
| 776 | TrieNode::Leaf { prefix: Nibbles::default(), value: bytes!("02") }, |
| 777 | TrieNode::Empty, |
| 778 | TrieNode::Empty, |
| 779 | TrieNode::Empty, |
| 780 | TrieNode::Empty, |
| 781 | TrieNode::Empty, |
| 782 | TrieNode::Empty, |
| 783 | TrieNode::Empty, |
| 784 | TrieNode::Empty, |
| 785 | TrieNode::Empty, |
| 786 | TrieNode::Empty, |
| 787 | ], |
| 788 | }), |
| 789 | }; |
| 790 | |
| 791 | assert_eq!(node, expected); |
| 792 | } |
| 793 | |
| 794 | proptest::proptest! { |
| 795 | /// Differential test for inserting an arbitrary number of keys into an empty `TrieNode` / `HashBuilder`. |