From d2f3942c47a02bf02fcdfefe9fb9833887ae236b Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Wed, 16 Dec 2015 18:28:04 +0100 Subject: [PATCH] Tests for nonce & balance. --- src/state.rs | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/state.rs b/src/state.rs index 64086de83..528aaf035 100644 --- a/src/state.rs +++ b/src/state.rs @@ -176,22 +176,44 @@ fn playpen() { } #[test] -fn add_balance() { +fn alter_balance() { let mut s = State::new_temp(); let a = Address::from_str("0000000000000000000000000000000000000000").unwrap(); s.add_balance(&a, &U256::from(69u64)); assert_eq!(s.balance(&a), U256::from(69u64)); s.commit(); assert_eq!(s.balance(&a), U256::from(69u64)); + s.sub_balance(&a, &U256::from(42u64)); + assert_eq!(s.balance(&a), U256::from(27u64)); + s.commit(); + assert_eq!(s.balance(&a), U256::from(27u64)); } #[test] -fn balance() { +fn alter_nonce() { + let mut s = State::new_temp(); + let a = Address::from_str("0000000000000000000000000000000000000000").unwrap(); + s.inc_nonce(&a); + assert_eq!(s.nonce(&a), U256::from(1u64)); + s.inc_nonce(&a); + assert_eq!(s.nonce(&a), U256::from(2u64)); + s.commit(); + assert_eq!(s.nonce(&a), U256::from(2u64)); + s.inc_nonce(&a); + assert_eq!(s.nonce(&a), U256::from(3u64)); + s.commit(); + assert_eq!(s.nonce(&a), U256::from(3u64)); +} + +#[test] +fn balance_nonce() { let mut s = State::new_temp(); let a = Address::from_str("0000000000000000000000000000000000000000").unwrap(); assert_eq!(s.balance(&a), U256::from(0u64)); + assert_eq!(s.nonce(&a), U256::from(0u64)); s.commit(); assert_eq!(s.balance(&a), U256::from(0u64)); + assert_eq!(s.nonce(&a), U256::from(0u64)); } #[test]