test_: Added testing for isValidForNetworkComplianceV2
This commit is contained in:
parent
0f33076ceb
commit
e1f65fb531
|
@ -6,6 +6,8 @@ import (
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||||
|
|
||||||
|
"github.com/status-im/status-go/params"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -91,3 +93,54 @@ func TestCalculateTotalRestAmountV2(t *testing.T) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestIsValidForNetworkComplianceV2(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
name string
|
||||||
|
route []*PathV2
|
||||||
|
fromLockedAmount map[uint64]*hexutil.Big
|
||||||
|
expectedResult bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
name: "Valid route with required chain IDs included",
|
||||||
|
route: []*PathV2{
|
||||||
|
{From: ¶ms.Network{ChainID: 1}},
|
||||||
|
{From: ¶ms.Network{ChainID: 3}},
|
||||||
|
},
|
||||||
|
fromLockedAmount: map[uint64]*hexutil.Big{
|
||||||
|
1: (*hexutil.Big)(big.NewInt(100)),
|
||||||
|
2: (*hexutil.Big)(big.NewInt(0)),
|
||||||
|
},
|
||||||
|
expectedResult: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Invalid route with excluded chain ID",
|
||||||
|
route: []*PathV2{
|
||||||
|
{From: ¶ms.Network{ChainID: 2}},
|
||||||
|
},
|
||||||
|
fromLockedAmount: map[uint64]*hexutil.Big{
|
||||||
|
1: (*hexutil.Big)(big.NewInt(100)),
|
||||||
|
2: (*hexutil.Big)(big.NewInt(0)),
|
||||||
|
},
|
||||||
|
expectedResult: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "Route missing required chain ID",
|
||||||
|
route: []*PathV2{
|
||||||
|
{From: ¶ms.Network{ChainID: 3}},
|
||||||
|
},
|
||||||
|
fromLockedAmount: map[uint64]*hexutil.Big{
|
||||||
|
1: (*hexutil.Big)(big.NewInt(100)),
|
||||||
|
2: (*hexutil.Big)(big.NewInt(50)),
|
||||||
|
},
|
||||||
|
expectedResult: false,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tt := range tests {
|
||||||
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
|
result := isValidForNetworkComplianceV2(tt.route, tt.fromLockedAmount)
|
||||||
|
assert.Equal(t, tt.expectedResult, result)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue