MCPcopy Create free account
hub / github.com/CPChain/chain / TestInvalidTransactions

Function TestInvalidTransactions

core/tx_pool_test.go:227–262  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

225}
226
227func TestInvalidTransactions(t *testing.T) {
228 t.Parallel()
229
230 pool, key := setupTxPool()
231 defer pool.Stop()
232
233 tx := transaction(0, 100, key)
234 from, _ := deriveSender(tx)
235
236 pool.currentState.AddBalance(from, big.NewInt(1))
237 if err := pool.AddRemote(tx); err != ErrInsufficientFunds {
238 t.Error("expected", ErrInsufficientFunds)
239 }
240
241 balance := new(big.Int).Add(tx.Value(), new(big.Int).Mul(new(big.Int).SetUint64(tx.Gas()), tx.GasPrice()))
242 pool.currentState.AddBalance(from, balance)
243 if err := pool.AddRemote(tx); err != ErrIntrinsicGas {
244 t.Error("expected", ErrIntrinsicGas, "got", err)
245 }
246
247 pool.currentState.SetNonce(from, 1)
248 pool.currentState.AddBalance(from, big.NewInt(0xffffffffffffff))
249 tx = transaction(0, 100000, key)
250 if err := pool.AddRemote(tx); err != ErrNonceTooLow {
251 t.Error("expected", ErrNonceTooLow)
252 }
253
254 tx = transaction(1, 100000, key)
255 pool.gasPrice = big.NewInt(1000)
256 if err := pool.AddRemote(tx); err != ErrUnderpriced {
257 t.Error("expected", ErrUnderpriced, "got", err)
258 }
259 if err := pool.AddLocal(tx); err != nil {
260 t.Error("expected", nil, "got", err)
261 }
262}
263
264func TestTransactionQueue(t *testing.T) {
265 t.Parallel()

Callers

nothing calls this directly

Calls 13

setupTxPoolFunction · 0.85
transactionFunction · 0.85
deriveSenderFunction · 0.85
AddRemoteMethod · 0.80
AddLocalMethod · 0.80
StopMethod · 0.65
AddBalanceMethod · 0.65
ErrorMethod · 0.65
AddMethod · 0.65
ValueMethod · 0.65
GasMethod · 0.65
GasPriceMethod · 0.65

Tested by

no test coverage detected