Fixing tests
This commit is contained in:
		
							parent
							
								
									c028f106b1
								
							
						
					
					
						commit
						022ccb5bce
					
				@ -81,10 +81,11 @@ impl KeyDirectory for NullDir {
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	fn insert(&self, account: SafeAccount) -> Result<SafeAccount, SSError> {
 | 
						fn insert(&self, account: SafeAccount) -> Result<SafeAccount, SSError> {
 | 
				
			||||||
		self.accounts.write()
 | 
							let mut lock = self.accounts.write();
 | 
				
			||||||
			.entry(account.address.clone())
 | 
							let mut accounts = lock.entry(account.address.clone()).or_insert_with(Vec::new);
 | 
				
			||||||
			.or_insert_with(Vec::new)
 | 
							// If the filename is the same we just need to replace the entry
 | 
				
			||||||
			.push(account.clone());
 | 
							accounts.retain(|acc| acc.filename != account.filename);
 | 
				
			||||||
 | 
							accounts.push(account.clone());
 | 
				
			||||||
		Ok(account)
 | 
							Ok(account)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -220,6 +220,9 @@ impl EthMultiStore {
 | 
				
			|||||||
		// update cache
 | 
							// update cache
 | 
				
			||||||
		let mut cache = self.cache.write();
 | 
							let mut cache = self.cache.write();
 | 
				
			||||||
		let mut accounts = cache.entry(account.address.clone()).or_insert_with(Vec::new);
 | 
							let mut accounts = cache.entry(account.address.clone()).or_insert_with(Vec::new);
 | 
				
			||||||
 | 
							// TODO [ToDr] That is crappy way of overcoming set_name, set_meta, etc.
 | 
				
			||||||
 | 
							// Avoid cloning instead!
 | 
				
			||||||
 | 
							accounts.retain(|acc| acc.filename != account.filename);
 | 
				
			||||||
		accounts.push(account);
 | 
							accounts.push(account);
 | 
				
			||||||
		Ok(())
 | 
							Ok(())
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
				
			|||||||
@ -267,7 +267,7 @@ mod tests {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		// when
 | 
							// when
 | 
				
			||||||
		let res = serde_json::to_string(&response);
 | 
							let res = serde_json::to_string(&response);
 | 
				
			||||||
		let expected = r#"{"result":"0x0000000000000000000000000000000000000000","token":"test-token"}"#;
 | 
							let expected = r#"{"result":"0x0000000000000000000000000000000000000000000000000000000000000000","token":"test-token"}"#;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// then
 | 
							// then
 | 
				
			||||||
		assert_eq!(res.unwrap(), expected.to_owned());
 | 
							assert_eq!(res.unwrap(), expected.to_owned());
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user