@@ -11,6 +11,7 @@ import (
1111 "github.com/NethermindEth/juno/core/felt"
1212 "github.com/NethermindEth/juno/rpc/rpccore"
1313 rpcv9 "github.com/NethermindEth/juno/rpc/v9"
14+ "github.com/NethermindEth/juno/validator"
1415 "github.com/stretchr/testify/require"
1516)
1617
@@ -56,6 +57,24 @@ func TestLazySlice(t *testing.T) {
5657 nil ,
5758 )
5859 })
60+
61+ // This test ensures that the validation logic works for the values inside the Data slice.
62+ t .Run ("ValidateRequiredFields" , func (t * testing.T ) {
63+ type BroadcastedTxLimitSlice = rpccore.LimitSlice [
64+ rpcv9.BroadcastedTransaction ,
65+ rpccore.SimulationLimit ,
66+ ]
67+
68+ withEmptyValues := BroadcastedTxLimitSlice {
69+ Data : make ([]rpcv9.BroadcastedTransaction , 10 ),
70+ }
71+
72+ validate := validator .Validator ()
73+ // The [rpcv9.BroadcastedTransaction] struct contains 'validate:...' json tags,
74+ // so it should fail here since we're not filling them with valid values.
75+ err := validate .Struct (withEmptyValues )
76+ require .Error (t , err , "Validation is not working for the values inside the Data slice" )
77+ })
5978}
6079
6180func runTest [T any , L rpccore.Limit ](
0 commit comments