removed redundant PodAccount::new method (#7928)
* removed redundant PodAccount::new method * fixed failing test
This commit is contained in:
		
							parent
							
								
									b77771171d
								
							
						
					
					
						commit
						4bda6efed0
					
				@ -43,12 +43,6 @@ pub struct PodAccount {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl PodAccount {
 | 
			
		||||
	/// Construct new object.
 | 
			
		||||
	#[cfg(test)]
 | 
			
		||||
	pub fn new(balance: U256, nonce: U256, code: Bytes, storage: BTreeMap<H256, H256>) -> PodAccount {
 | 
			
		||||
		PodAccount { balance: balance, nonce: nonce, code: Some(code), storage: storage }
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/// Convert Account to a PodAccount.
 | 
			
		||||
	/// NOTE: This will silently fail unless the account is fully cached.
 | 
			
		||||
	pub fn from_account(acc: &Account) -> PodAccount {
 | 
			
		||||
 | 
			
		||||
@ -89,7 +89,12 @@ mod test {
 | 
			
		||||
 | 
			
		||||
	#[test]
 | 
			
		||||
	fn create_delete() {
 | 
			
		||||
		let a = PodState::from(map![ 1.into() => PodAccount::new(69.into(), 0.into(), vec![], map![]) ]);
 | 
			
		||||
		let a = PodState::from(map![ 1.into() => PodAccount {
 | 
			
		||||
			balance: 69.into(),
 | 
			
		||||
			nonce: 0.into(),
 | 
			
		||||
			code: Some(Vec::new()),
 | 
			
		||||
			storage: map![],
 | 
			
		||||
		}]);
 | 
			
		||||
		assert_eq!(super::diff_pod(&a, &PodState::new()), StateDiff { raw: map![
 | 
			
		||||
			1.into() => AccountDiff{
 | 
			
		||||
				balance: Diff::Died(69.into()),
 | 
			
		||||
@ -110,10 +115,25 @@ mod test {
 | 
			
		||||
 | 
			
		||||
	#[test]
 | 
			
		||||
	fn create_delete_with_unchanged() {
 | 
			
		||||
		let a = PodState::from(map![ 1.into() => PodAccount::new(69.into(), 0.into(), vec![], map![]) ]);
 | 
			
		||||
		let a = PodState::from(map![ 1.into() => PodAccount {
 | 
			
		||||
			balance: 69.into(),
 | 
			
		||||
			nonce: 0.into(),
 | 
			
		||||
			code: Some(Vec::new()),
 | 
			
		||||
			storage: map![],
 | 
			
		||||
		}]);
 | 
			
		||||
		let b = PodState::from(map![
 | 
			
		||||
			1.into() => PodAccount::new(69.into(), 0.into(), vec![], map![]),
 | 
			
		||||
			2.into() => PodAccount::new(69.into(), 0.into(), vec![], map![])
 | 
			
		||||
			1.into() => PodAccount {
 | 
			
		||||
				balance: 69.into(),
 | 
			
		||||
				nonce: 0.into(),
 | 
			
		||||
				code: Some(Vec::new()),
 | 
			
		||||
				storage: map![],
 | 
			
		||||
			},
 | 
			
		||||
			2.into() => PodAccount {
 | 
			
		||||
				balance: 69.into(),
 | 
			
		||||
				nonce: 0.into(),
 | 
			
		||||
				code: Some(Vec::new()),
 | 
			
		||||
				storage: map![],
 | 
			
		||||
			}
 | 
			
		||||
		]);
 | 
			
		||||
		assert_eq!(super::diff_pod(&a, &b), StateDiff { raw: map![
 | 
			
		||||
			2.into() => AccountDiff{
 | 
			
		||||
@ -136,12 +156,32 @@ mod test {
 | 
			
		||||
	#[test]
 | 
			
		||||
	fn change_with_unchanged() {
 | 
			
		||||
		let a = PodState::from(map![
 | 
			
		||||
			1.into() => PodAccount::new(69.into(), 0.into(), vec![], map![]),
 | 
			
		||||
			2.into() => PodAccount::new(69.into(), 0.into(), vec![], map![])
 | 
			
		||||
			1.into() => PodAccount {
 | 
			
		||||
				balance: 69.into(),
 | 
			
		||||
				nonce: 0.into(),
 | 
			
		||||
				code: Some(Vec::new()),
 | 
			
		||||
				storage: map![],
 | 
			
		||||
			},
 | 
			
		||||
			2.into() => PodAccount {
 | 
			
		||||
				balance: 69.into(),
 | 
			
		||||
				nonce: 0.into(),
 | 
			
		||||
				code: Some(Vec::new()),
 | 
			
		||||
				storage: map![],
 | 
			
		||||
			}
 | 
			
		||||
		]);
 | 
			
		||||
		let b = PodState::from(map![
 | 
			
		||||
			1.into() => PodAccount::new(69.into(), 1.into(), vec![], map![]),
 | 
			
		||||
			2.into() => PodAccount::new(69.into(), 0.into(), vec![], map![])
 | 
			
		||||
			1.into() => PodAccount {
 | 
			
		||||
				balance: 69.into(),
 | 
			
		||||
				nonce: 1.into(),
 | 
			
		||||
				code: Some(Vec::new()),
 | 
			
		||||
				storage: map![],
 | 
			
		||||
			},
 | 
			
		||||
			2.into() => PodAccount {
 | 
			
		||||
				balance: 69.into(),
 | 
			
		||||
				nonce: 0.into(),
 | 
			
		||||
				code: Some(Vec::new()),
 | 
			
		||||
				storage: map![],
 | 
			
		||||
			}
 | 
			
		||||
		]);
 | 
			
		||||
		assert_eq!(super::diff_pod(&a, &b), StateDiff { raw: map![
 | 
			
		||||
			1.into() => AccountDiff{
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user