MCPcopy Create free account
hub / github.com/33cn/chain33 / TestCheckTx

Function TestCheckTx

executor/executor_test.go:287–316  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

285 assert.Equal(t, true, api.IsAPIEnvError(err))
286}
287func TestCheckTx(t *testing.T) {
288 exec, q := initEnv(types.ReadFile("../cmd/chain33/chain33.test.toml"))
289 cfg := exec.client.GetConfig()
290
291 store := store.New(cfg)
292 store.SetQueueClient(q.Client())
293 defer store.Close()
294
295 addr, priv := util.Genaddress()
296
297 tx := util.CreateCoinsTx(cfg, priv, addr, types.DefaultCoinPrecision)
298 tx.Execer = []byte("user.xxx")
299 tx.To = address.ExecAddress("user.xxx")
300 tx.Fee = 2 * types.DefaultCoinPrecision
301 tx.Sign(types.SECP256K1, priv)
302
303 var txs []*types.Transaction
304 txs = append(txs, tx)
305 ctx := &executorCtx{
306 stateHash: nil,
307 height: 0,
308 blocktime: time.Now().Unix(),
309 difficulty: 1,
310 mainHash: nil,
311 parentHash: nil,
312 }
313 execute := newExecutor(ctx, exec, nil, txs, nil)
314 err := execute.execCheckTx(tx, 0)
315 assert.Equal(t, err, types.ErrNoBalance)
316}
317
318func TestExecutorUpgradeMsg(t *testing.T) {
319 exec, q := initEnv(types.GetDefaultCfgstring())

Callers

nothing calls this directly

Calls 13

ReadFileFunction · 0.92
NewFunction · 0.92
GenaddressFunction · 0.92
CreateCoinsTxFunction · 0.92
ExecAddressFunction · 0.92
newExecutorFunction · 0.85
execCheckTxMethod · 0.80
initEnvFunction · 0.70
GetConfigMethod · 0.65
SetQueueClientMethod · 0.65
ClientMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected