Added tests for valid transactions
This commit is contained in:
		
							parent
							
								
									48d2a8b8ee
								
							
						
					
					
						commit
						6cf61039cf
					
				| @ -18,15 +18,6 @@ func (self stateQuery) GetAccount(addr []byte) *state.StateObject { | |||||||
| 	return state.NewStateObject(addr) | 	return state.NewStateObject(addr) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // State query interface
 |  | ||||||
| type invalidStateQuery struct{} |  | ||||||
| 
 |  | ||||||
| func (self invalidStateQuery) GetAccount(addr []byte) *state.StateObject { |  | ||||||
| 	o := state.NewStateObject(addr) |  | ||||||
| 	o.Nonce++ |  | ||||||
| 	return o |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| func transaction() *types.Transaction { | func transaction() *types.Transaction { | ||||||
| 	return types.NewTransactionMessage(make([]byte, 20), ethutil.Big0, ethutil.Big0, ethutil.Big0, nil) | 	return types.NewTransactionMessage(make([]byte, 20), ethutil.Big0, ethutil.Big0, ethutil.Big0, nil) | ||||||
| } | } | ||||||
| @ -72,11 +63,19 @@ func TestRemoveSet(t *testing.T) { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func TestRemoveInvalid(t *testing.T) { | func TestRemoveInvalid(t *testing.T) { | ||||||
| 	pool, _ := setup() | 	pool, key := setup() | ||||||
| 	tx1 := transaction() | 	tx1 := transaction() | ||||||
| 	pool.pool.Add(tx1) | 	pool.pool.Add(tx1) | ||||||
| 	pool.RemoveInvalid(invalidStateQuery{}) | 	pool.RemoveInvalid(stateQuery{}) | ||||||
| 	if pool.Size() > 0 { | 	if pool.Size() > 0 { | ||||||
| 		t.Error("expected pool size to be 0") | 		t.Error("expected pool size to be 0") | ||||||
| 	} | 	} | ||||||
|  | 
 | ||||||
|  | 	tx1.SetNonce(1) | ||||||
|  | 	tx1.SignECDSA(key) | ||||||
|  | 	pool.pool.Add(tx1) | ||||||
|  | 	pool.RemoveInvalid(stateQuery{}) | ||||||
|  | 	if pool.Size() != 1 { | ||||||
|  | 		t.Error("expected pool size to be 1, is", pool.Size()) | ||||||
|  | 	} | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user