Skip to content

Commit c210338

Browse files
committed
test(dataValidators): propagate NewUserAccount errors in bench stubs
Capture and return the error from state.NewUserAccount in the three mock AccountsStub closures instead of discarding it. The error path is only reachable on an empty address (not the case here), but the defensive check matches the file's existing error-handling pattern and silences the CodeRabbit nitpicks on PR #44.
1 parent b4ee8b0 commit c210338

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

core/process/dataValidators/txValidator_bench_test.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,10 @@ func buildBenchValidator(tb testing.TB, numSigners int, keygenCost int) (process
5555

5656
adb := &mock.AccountsStub{
5757
GetExistingAccountCalled: func(_ []byte) (state.AccountHandler, error) {
58-
acc, _ := state.NewUserAccount(addressMock)
58+
acc, err := state.NewUserAccount(addressMock)
59+
if err != nil {
60+
return nil, err
61+
}
5962
acc.Permissions = []*state.Permission{
6063
{
6164
Type: state.Permission_Owner,
@@ -262,7 +265,10 @@ func BenchmarkCheckTxValidity_RealEd25519(b *testing.B) {
262265
}
263266
adb := &mock.AccountsStub{
264267
GetExistingAccountCalled: func(_ []byte) (state.AccountHandler, error) {
265-
acc, _ := state.NewUserAccount(sharedAddr)
268+
acc, err := state.NewUserAccount(sharedAddr)
269+
if err != nil {
270+
return nil, err
271+
}
266272
acc.Permissions = []*state.Permission{
267273
{Type: state.Permission_Owner, Threshold: 1, Signers: signers},
268274
}
@@ -310,7 +316,10 @@ func TestBenchScaffolding_MultiSignerPathExecutes(t *testing.T) {
310316
signers := []*state.Key{{Address: addressMock, Weight: 1}, {Address: addressMock, Weight: 1}}
311317
adb := &mock.AccountsStub{
312318
GetExistingAccountCalled: func(_ []byte) (state.AccountHandler, error) {
313-
acc, _ := state.NewUserAccount(addressMock)
319+
acc, err := state.NewUserAccount(addressMock)
320+
if err != nil {
321+
return nil, err
322+
}
314323
acc.Permissions = []*state.Permission{{Type: state.Permission_Owner, Threshold: 1, Signers: signers}}
315324
return acc, nil
316325
},

0 commit comments

Comments
 (0)