Skip to content

Commit

Permalink
add testcase
Browse files Browse the repository at this point in the history
  • Loading branch information
libangzhu committed Feb 4, 2024
1 parent e08fefe commit daf4f80
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 5 deletions.
3 changes: 2 additions & 1 deletion cmd/chain33/chain33.fork.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ ForkCheckEthTxSort=0
ForkProxyExec=0
ForkMaxBlockFee=0
ForkMaxTxFeeV1=0
ForkMaxBlockFee=0
ForkMaxTxFeeV2=0


[fork.sub.none]
ForkUseTimeDelay=0
Expand Down
26 changes: 23 additions & 3 deletions system/consensus/solo/solo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,33 @@ func TestSolo(t *testing.T) {
mock33.GetAPI().SendTx(txs[i])
}
mock33.WaitHeight(2)
//test feelimit txs ,blockfeelimit

privkey := mock33.GetGenesisKey()
txs = util.GenCoinsTxs(cfg, nil, 10)
for i := 0; i < 10; i++ {
//每笔交易手续费20个比特元
txs[i].Fee = 20 * 1e8
txs[i].Sign(types.SECP256K1, privkey)
}
for i := 0; i < len(txs); i++ {
t.Log(txs[i].GetTxFee())
mock33.GetAPI().SendTx(txs[i])
}
time.Sleep(time.Second * 10)
t.Log("current height:", mock33.GetBlockChain().GetBlockHeight())
for h := 3; h <= int(mock33.GetBlockChain().GetBlockHeight()); h++ {
t.Log("blockfee:", mock33.GetBlock(int64(h)).Fee(), "blockheight:", h, "txnum:", len(mock33.GetBlock(int64(h)).Txs))
assert.True(t, mock33.GetBlock(int64(h)).Fee() < types.MaxBlockFee)
}

}

var (
tlog = log15.New("module", "test solo")
)

//mempool发送交易 10000tx/s
// mempool发送交易 10000tx/s
func BenchmarkSendTx(b *testing.B) {
if testing.Short() {
b.Skip("skipping in short mode.")
Expand Down Expand Up @@ -244,7 +264,7 @@ func createCoinsTx(cfg *types.Chain33Config, to string, txHeight int64) *types.T
return tx
}

//测试solo并发
// 测试solo并发
func BenchmarkSolo(b *testing.B) {

if testing.Short() {
Expand Down Expand Up @@ -392,7 +412,7 @@ func BenchmarkCheckSign(b *testing.B) {
}
}

//消息队列发送性能, 80w /s
// 消息队列发送性能, 80w /s
func BenchmarkMsgQueue(b *testing.B) {
if testing.Short() {
b.Skip("skipping in short mode.")
Expand Down
8 changes: 7 additions & 1 deletion types/defaultcfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ poolCacheSize=102400
minTxFeeRate=100000
maxTxNumPerAccount=100000
[mver.mempool.ForkMaxTxFeeV1]
maxTxFee=5000000000
[mver.mempool.ForkMaxTxFeeV2]
maxTxFee=2000000000
[consensus]
name="solo"
minerstart=true
Expand Down Expand Up @@ -250,7 +256,7 @@ useBalance=false
jdkPath="../../../../build/j2sdk-image"
`

//GetDefaultCfgstring ...
// GetDefaultCfgstring ...
func GetDefaultCfgstring() string {
return cfgstring
}
2 changes: 2 additions & 0 deletions types/testdata/chain33.toml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ ForkV24TxGroupPara= 806578
ForkStateDBSet=-1
ForkMaxTxFeeV1=30839600
ForkMaxTxFeeV2=30939600
ForkMaxBlockFee=30949600

[fork.sub.manage]
Enable=120000
ForkV11ManageExec= 400000
Expand Down

0 comments on commit daf4f80

Please sign in to comment.