@@ -25,6 +25,12 @@ import (
2525 "github.com/rollkit/rollkit/types"
2626)
2727
28+ func prepareProposalResponse (_ context.Context , req * abci.RequestPrepareProposal ) (* abci.ResponsePrepareProposal , error ) {
29+ return & abci.ResponsePrepareProposal {
30+ Txs : req .Txs ,
31+ }, nil
32+ }
33+
2834func doTestCreateBlock (t * testing.T ) {
2935 assert := assert .New (t )
3036 require := require .New (t )
@@ -33,7 +39,8 @@ func doTestCreateBlock(t *testing.T) {
3339
3440 app := & mocks.Application {}
3541 app .On ("CheckTx" , mock .Anything , mock .Anything ).Return (& abci.ResponseCheckTx {}, nil )
36-
42+ app .On ("PrepareProposal" , mock .Anything , mock .Anything ).Return (prepareProposalResponse )
43+ app .On ("ProcessProposal" , mock .Anything , mock .Anything ).Return (& abci.ResponseProcessProposal {Status : abci .ResponseProcessProposal_ACCEPT }, nil )
3744 fmt .Println ("App On CheckTx" )
3845 client , err := proxy .NewLocalClientCreator (app ).NewABCIClient ()
3946 fmt .Println ("Created New Local Client" )
@@ -65,15 +72,17 @@ func doTestCreateBlock(t *testing.T) {
6572 state .NextValidators = cmtypes .NewValidatorSet (validators )
6673
6774 // empty block
68- block := executor .CreateBlock (1 , & types.Commit {}, []byte {}, state )
75+ block , err := executor .CreateBlock (context .Background (), 1 , & types.Commit {}, []byte {}, state )
76+ require .NoError (err )
6977 require .NotNil (block )
7078 assert .Empty (block .Data .Txs )
7179 assert .Equal (uint64 (1 ), block .Height ())
7280
7381 // one small Tx
7482 err = mpool .CheckTx ([]byte {1 , 2 , 3 , 4 }, func (r * abci.ResponseCheckTx ) {}, mempool.TxInfo {})
7583 require .NoError (err )
76- block = executor .CreateBlock (2 , & types.Commit {}, []byte {}, state )
84+ block , err = executor .CreateBlock (context .Background (), 2 , & types.Commit {}, []byte {}, state )
85+ require .NoError (err )
7786 require .NotNil (block )
7887 assert .Equal (uint64 (2 ), block .Height ())
7988 assert .Len (block .Data .Txs , 1 )
@@ -83,7 +92,8 @@ func doTestCreateBlock(t *testing.T) {
8392 require .NoError (err )
8493 err = mpool .CheckTx (make ([]byte , 100 ), func (r * abci.ResponseCheckTx ) {}, mempool.TxInfo {})
8594 require .NoError (err )
86- block = executor .CreateBlock (3 , & types.Commit {}, []byte {}, state )
95+ block , err = executor .CreateBlock (context .Background (), 3 , & types.Commit {}, []byte {}, state )
96+ require .NoError (err )
8797 require .NotNil (block )
8898 assert .Len (block .Data .Txs , 2 )
8999}
@@ -105,6 +115,8 @@ func doTestApplyBlock(t *testing.T) {
105115 app := & mocks.Application {}
106116 app .On ("CheckTx" , mock .Anything , mock .Anything ).Return (& abci.ResponseCheckTx {}, nil )
107117 app .On ("Commit" , mock .Anything , mock .Anything ).Return (& abci.ResponseCommit {}, nil )
118+ app .On ("PrepareProposal" , mock .Anything , mock .Anything ).Return (prepareProposalResponse )
119+ app .On ("ProcessProposal" , mock .Anything , mock .Anything ).Return (& abci.ResponseProcessProposal {Status : abci .ResponseProcessProposal_ACCEPT }, nil )
108120 app .On ("FinalizeBlock" , mock .Anything , mock .Anything ).Return (
109121 func (_ context.Context , req * abci.RequestFinalizeBlock ) (* abci.ResponseFinalizeBlock , error ) {
110122 txResults := make ([]* abci.ExecTxResult , len (req .Txs ))
@@ -167,7 +179,8 @@ func doTestApplyBlock(t *testing.T) {
167179
168180 err = mpool .CheckTx ([]byte {1 , 2 , 3 , 4 }, func (r * abci.ResponseCheckTx ) {}, mempool.TxInfo {})
169181 require .NoError (err )
170- block := executor .CreateBlock (1 , & types.Commit {Signatures : []types.Signature {types .Signature ([]byte {1 , 1 , 1 })}}, []byte {}, state )
182+ block , err := executor .CreateBlock (context .Background (), 1 , & types.Commit {Signatures : []types.Signature {types .Signature ([]byte {1 , 1 , 1 })}}, []byte {}, state )
183+ require .NoError (err )
171184 require .NotNil (block )
172185 assert .Equal (uint64 (1 ), block .Height ())
173186 assert .Len (block .Data .Txs , 1 )
@@ -196,7 +209,8 @@ func doTestApplyBlock(t *testing.T) {
196209 require .NoError (mpool .CheckTx ([]byte {5 , 6 , 7 , 8 , 9 }, func (r * abci.ResponseCheckTx ) {}, mempool.TxInfo {}))
197210 require .NoError (mpool .CheckTx ([]byte {1 , 2 , 3 , 4 , 5 }, func (r * abci.ResponseCheckTx ) {}, mempool.TxInfo {}))
198211 require .NoError (mpool .CheckTx (make ([]byte , 90 ), func (r * abci.ResponseCheckTx ) {}, mempool.TxInfo {}))
199- block = executor .CreateBlock (2 , & types.Commit {Signatures : []types.Signature {types .Signature ([]byte {1 , 1 , 1 })}}, []byte {}, newState )
212+ block , err = executor .CreateBlock (context .Background (), 2 , & types.Commit {Signatures : []types.Signature {types .Signature ([]byte {1 , 1 , 1 })}}, []byte {}, newState )
213+ require .NoError (err )
200214 require .NotNil (block )
201215 assert .Equal (uint64 (2 ), block .Height ())
202216 assert .Len (block .Data .Txs , 3 )
0 commit comments