-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add UTs to Processor Execute()
#1890
Changes from 1 commit
fe432e2
81b93f8
12f310d
3e9f766
467d7b8
5cdc674
d3920c0
dd9c5a9
d2da050
8791a01
37dc75c
3fa517d
3598dc7
33e0fe4
2bbc489
390c816
7aa3fd1
9cd1db1
3395a71
c5750f8
167755c
d56316e
8b4f12e
a51526d
6acef69
d9e0a43
c0934f6
de7142d
7f3e6ea
6afe172
d23cd97
0ef1f29
fc22e50
4b12eee
c4aeff6
f5036f5
0040c01
9b6b114
41c7fb2
5844161
dae8bde
4ca4ebf
9f50828
a483f4a
2d3bf36
73453cc
f39c8f8
a5ba263
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,7 +71,7 @@ func TestProcessorExecute(t *testing.T) { | |
workers workers.Workers | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed |
||
isNormalOp bool | ||
db merkledb.MerkleDB | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
createBlock func(ids.ID) *chain.StatelessBlock | ||
newBlockF func(ids.ID) *chain.StatelessBlock | ||
expectedErr error | ||
}{ | ||
{ | ||
|
@@ -85,13 +85,13 @@ func TestProcessorExecute(t *testing.T) { | |
require.NoError(t, db.Put([]byte(feeKey), []byte{})) | ||
return db | ||
}(), | ||
createBlock: createValidBlock, | ||
newBlockF: createValidBlock, | ||
}, | ||
{ | ||
name: "block timestamp too late", | ||
validityWindow: &validitywindowtest.MockTimeValidityWindow[*chain.Transaction]{}, | ||
workers: workers.NewSerial(), | ||
createBlock: func(root ids.ID) *chain.StatelessBlock { | ||
newBlockF: func(root ids.ID) *chain.StatelessBlock { | ||
block, err := chain.NewStatelessBlock( | ||
ids.Empty, | ||
time.Now().Add(chain.FutureBound).UnixMilli()+int64(time.Second), | ||
|
@@ -114,15 +114,15 @@ func TestProcessorExecute(t *testing.T) { | |
return w | ||
}(), | ||
db: createDB(), | ||
createBlock: createValidBlock, | ||
newBlockF: createValidBlock, | ||
expectedErr: workers.ErrShutdown, | ||
}, | ||
{ | ||
name: "failed to get parent height", | ||
validityWindow: &validitywindowtest.MockTimeValidityWindow[*chain.Transaction]{}, | ||
workers: workers.NewSerial(), | ||
db: createDB(), | ||
createBlock: createValidBlock, | ||
newBlockF: createValidBlock, | ||
expectedErr: chain.ErrFailedToFetchParentHeight, | ||
}, | ||
{ | ||
|
@@ -134,7 +134,7 @@ func TestProcessorExecute(t *testing.T) { | |
require.NoError(t, db.Put([]byte(heightKey), []byte{})) | ||
return db | ||
}(), | ||
createBlock: createValidBlock, | ||
newBlockF: createValidBlock, | ||
expectedErr: chain.ErrFailedToParseParentHeight, | ||
}, | ||
{ | ||
|
@@ -146,7 +146,7 @@ func TestProcessorExecute(t *testing.T) { | |
require.NoError(t, db.Put([]byte(heightKey), binary.BigEndian.AppendUint64(nil, 0))) | ||
return db | ||
}(), | ||
createBlock: func(parentRoot ids.ID) *chain.StatelessBlock { | ||
newBlockF: func(parentRoot ids.ID) *chain.StatelessBlock { | ||
block, err := chain.NewStatelessBlock( | ||
ids.Empty, | ||
time.Now().UnixMilli(), | ||
|
@@ -168,7 +168,7 @@ func TestProcessorExecute(t *testing.T) { | |
require.NoError(t, db.Put([]byte(heightKey), binary.BigEndian.AppendUint64(nil, 0))) | ||
return db | ||
}(), | ||
createBlock: createValidBlock, | ||
newBlockF: createValidBlock, | ||
expectedErr: chain.ErrFailedToFetchParentTimestamp, | ||
}, | ||
{ | ||
|
@@ -181,7 +181,7 @@ func TestProcessorExecute(t *testing.T) { | |
require.NoError(t, db.Put([]byte(timestampKey), []byte{})) | ||
return db | ||
}(), | ||
createBlock: createValidBlock, | ||
newBlockF: createValidBlock, | ||
expectedErr: chain.ErrFailedToParseParentTimestamp, | ||
}, | ||
{ | ||
|
@@ -194,7 +194,7 @@ func TestProcessorExecute(t *testing.T) { | |
require.NoError(t, db.Put([]byte(timestampKey), binary.BigEndian.AppendUint64(nil, 0))) | ||
return db | ||
}(), | ||
createBlock: func(parentRoot ids.ID) *chain.StatelessBlock { | ||
newBlockF: func(parentRoot ids.ID) *chain.StatelessBlock { | ||
block, err := chain.NewStatelessBlock( | ||
ids.Empty, | ||
0, | ||
aaronbuchwald marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
@@ -229,7 +229,7 @@ func TestProcessorExecute(t *testing.T) { | |
require.NoError(t, db.Put([]byte(timestampKey), binary.BigEndian.AppendUint64(nil, 0))) | ||
return db | ||
}(), | ||
createBlock: func(parentRoot ids.ID) *chain.StatelessBlock { | ||
newBlockF: func(parentRoot ids.ID) *chain.StatelessBlock { | ||
block, err := chain.NewStatelessBlock( | ||
ids.Empty, | ||
0, | ||
aaronbuchwald marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
@@ -252,7 +252,7 @@ func TestProcessorExecute(t *testing.T) { | |
require.NoError(t, db.Put([]byte(timestampKey), binary.BigEndian.AppendUint64(nil, 0))) | ||
return db | ||
}(), | ||
createBlock: createValidBlock, | ||
newBlockF: createValidBlock, | ||
expectedErr: chain.ErrFailedToFetchParentFee, | ||
}, | ||
{ | ||
|
@@ -271,7 +271,7 @@ func TestProcessorExecute(t *testing.T) { | |
require.NoError(t, db.Put([]byte(feeKey), []byte{})) | ||
return db | ||
}(), | ||
createBlock: createValidBlock, | ||
newBlockF: createValidBlock, | ||
expectedErr: errMockVerifyExpiryReplayProtection, | ||
}, | ||
{ | ||
|
@@ -285,7 +285,7 @@ func TestProcessorExecute(t *testing.T) { | |
require.NoError(t, db.Put([]byte(feeKey), []byte{})) | ||
return db | ||
}(), | ||
createBlock: func(parentRoot ids.ID) *chain.StatelessBlock { | ||
newBlockF: func(parentRoot ids.ID) *chain.StatelessBlock { | ||
block, err := chain.NewStatelessBlock( | ||
ids.Empty, | ||
time.Now().UnixMilli(), | ||
|
@@ -327,7 +327,7 @@ func TestProcessorExecute(t *testing.T) { | |
require.NoError(t, db.Put([]byte(feeKey), []byte{})) | ||
return db | ||
}(), | ||
createBlock: func(ids.ID) *chain.StatelessBlock { | ||
newBlockF: func(ids.ID) *chain.StatelessBlock { | ||
block, err := chain.NewStatelessBlock( | ||
ids.Empty, | ||
time.Now().UnixMilli(), | ||
|
@@ -351,7 +351,7 @@ func TestProcessorExecute(t *testing.T) { | |
require.NoError(t, db.Put([]byte(feeKey), []byte{})) | ||
return db | ||
}(), | ||
createBlock: func(parentRoot ids.ID) *chain.StatelessBlock { | ||
newBlockF: func(parentRoot ids.ID) *chain.StatelessBlock { | ||
block, err := chain.NewStatelessBlock( | ||
ids.Empty, | ||
time.Now().UnixMilli(), | ||
|
@@ -414,7 +414,7 @@ func TestProcessorExecute(t *testing.T) { | |
_, err = processor.Execute( | ||
ctx, | ||
tt.db, | ||
chain.NewExecutionBlock(tt.createBlock(root)), | ||
chain.NewExecutionBlock(tt.newBlockF(root)), | ||
tt.isNormalOp, | ||
) | ||
r.ErrorIs(err, tt.expectedErr) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (separate PR) - could we confirm the post state is what we expect as well ie. we should make sure that the metadata is updated correctly and that tx/action execution (include successful and failed w/ rollbacks) has the expected effect There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ack |
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: move this to be adjacent to
validityWindow
so that dependencies and parameters are grouped to be adjacent with each otherThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done