Skip to content

Commit

Permalink
fix: test + lint
Browse files Browse the repository at this point in the history
  • Loading branch information
rianhughes authored and wojciechos committed Sep 17, 2024
1 parent 4f47c7c commit c70abd0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
9 changes: 5 additions & 4 deletions rpc/estimate_fee_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,16 @@ func TestEstimateMessageFeeV0_6(t *testing.T) {
}, gomock.Any(), &utils.Mainnet, gomock.Any(), false, true, false).DoAndReturn(
func(txns []core.Transaction, declaredClasses []core.Class, paidFeesOnL1 []*felt.Felt, blockInfo *vm.BlockInfo,
state core.StateReader, network *utils.Network, skipChargeFee, skipValidate, errOnRevert, useBlobData bool,
) ([]*felt.Felt, []*felt.Felt, []vm.TransactionTrace, uint64, error) {
) ([]*felt.Felt, []core.GasConsumed, []vm.TransactionTrace, uint64, error) {
require.Len(t, txns, 1)
assert.NotNil(t, txns[0].(*core.L1HandlerTransaction))

assert.Empty(t, declaredClasses)
assert.Len(t, paidFeesOnL1, 1)

actualFee := new(felt.Felt).Mul(expectedGasConsumed, blockInfo.Header.GasPrice)
return []*felt.Felt{actualFee}, []*felt.Felt{&felt.Zero}, []vm.TransactionTrace{{
daGas := []core.GasConsumed{{L1Gas: 0, L1DataGas: 0}}
return []*felt.Felt{actualFee}, daGas, []vm.TransactionTrace{{
StateDiff: &vm.StateDiff{
StorageDiffs: []vm.StorageDiff{},
Nonces: []vm.Nonce{},
Expand Down Expand Up @@ -116,7 +117,7 @@ func TestEstimateFee(t *testing.T) {
blockInfo := vm.BlockInfo{Header: &core.Header{}}
t.Run("ok with zero values", func(t *testing.T) {
mockVM.EXPECT().Execute([]core.Transaction{}, nil, []*felt.Felt{}, &blockInfo, mockState, n, true, false, true, true).
Return([]*felt.Felt{}, []*felt.Felt{}, []vm.TransactionTrace{}, uint64(123), nil)
Return([]*felt.Felt{}, []core.GasConsumed{}, []vm.TransactionTrace{}, uint64(123), nil)

_, httpHeader, err := handler.EstimateFee([]rpc.BroadcastedTransaction{}, []rpc.SimulationFlag{}, rpc.BlockID{Latest: true})
require.Nil(t, err)
Expand All @@ -125,7 +126,7 @@ func TestEstimateFee(t *testing.T) {

t.Run("ok with zero values, skip validate", func(t *testing.T) {
mockVM.EXPECT().Execute([]core.Transaction{}, nil, []*felt.Felt{}, &blockInfo, mockState, n, true, true, true, true).
Return([]*felt.Felt{}, []*felt.Felt{}, []vm.TransactionTrace{}, uint64(123), nil)
Return([]*felt.Felt{}, []core.GasConsumed{}, []vm.TransactionTrace{}, uint64(123), nil)

_, httpHeader, err := handler.EstimateFee([]rpc.BroadcastedTransaction{}, []rpc.SimulationFlag{rpc.SkipValidateFlag}, rpc.BlockID{Latest: true})
require.Nil(t, err)
Expand Down
4 changes: 2 additions & 2 deletions rpc/simulation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func TestSimulateTransactionsV0_6(t *testing.T) {
mockVM.EXPECT().Execute([]core.Transaction{}, nil, []*felt.Felt{}, &vm.BlockInfo{
Header: headsHeader,
}, mockState, n, true, false, false, false).
Return([]*felt.Felt{}, []*felt.Felt{}, []vm.TransactionTrace{}, stepsUsed, nil)
Return([]*felt.Felt{}, []core.GasConsumed{}, []vm.TransactionTrace{}, stepsUsed, nil)

_, httpHeader, err := handler.SimulateTransactionsV0_6(rpc.BlockID{Latest: true}, []rpc.BroadcastedTransaction{}, []rpc.SimulationFlag{rpc.SkipFeeChargeFlag})
require.Nil(t, err)
Expand All @@ -51,7 +51,7 @@ func TestSimulateTransactionsV0_6(t *testing.T) {
mockVM.EXPECT().Execute([]core.Transaction{}, nil, []*felt.Felt{}, &vm.BlockInfo{
Header: headsHeader,
}, mockState, n, false, true, false, false).
Return([]*felt.Felt{}, []*felt.Felt{}, []vm.TransactionTrace{}, stepsUsed, nil)
Return([]*felt.Felt{}, []core.GasConsumed{}, []vm.TransactionTrace{}, stepsUsed, nil)

_, httpHeader, err := handler.SimulateTransactionsV0_6(rpc.BlockID{Latest: true}, []rpc.BroadcastedTransaction{}, []rpc.SimulationFlag{rpc.SkipValidateFlag})
require.Nil(t, err)
Expand Down
4 changes: 2 additions & 2 deletions rpc/trace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func TestTraceTransaction(t *testing.T) {
}`, executionResources)
vmTrace := new(vm.TransactionTrace)
require.NoError(t, json.Unmarshal(json.RawMessage(vmTraceJSON), vmTrace))
consumedGas := []*felt.Felt{new(felt.Felt).SetUint64(1)}
consumedGas := []core.GasConsumed{{L1Gas: 1, L1DataGas: 0}}
overallFee := []*felt.Felt{new(felt.Felt).SetUint64(1)}
stepsUsed := uint64(123)
stepsUsedStr := "123"
Expand Down Expand Up @@ -249,7 +249,7 @@ func TestTraceTransaction(t *testing.T) {
}`, executionResources)
vmTrace := new(vm.TransactionTrace)
require.NoError(t, json.Unmarshal(json.RawMessage(vmTraceJSON), vmTrace))
consumedGas := []*felt.Felt{new(felt.Felt).SetUint64(1)}
consumedGas := []core.GasConsumed{{L1Gas: 1, L1DataGas: 0}}
overallFee := []*felt.Felt{new(felt.Felt).SetUint64(1)}
stepsUsed := uint64(123)
stepsUsedStr := "123"
Expand Down
2 changes: 1 addition & 1 deletion vm/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func JunoAppendActualFee(readerHandle C.uintptr_t, ptr unsafe.Pointer) {
}

//export JunoAppendDataGasConsumed
func JunoAppendDataGasConsumed(readerHandle C.uintptr_t, ptr unsafe.Pointer, ptr2 unsafe.Pointer) {
func JunoAppendDataGasConsumed(readerHandle C.uintptr_t, ptr, ptr2 unsafe.Pointer) {
context := unwrapContext(readerHandle)
context.daGas = append(context.daGas, core.GasConsumed{
L1Gas: makeFeltFromPtr(ptr).Uint64(),
Expand Down

0 comments on commit c70abd0

Please sign in to comment.