status-go/services/wallet/requests/router_input_community_params_test.go
Sale Djenic bf1ef87cc0 chore(wallet-community)_: move community transactions to the wallet router
- new file `contracts/community-tokens/contracts.go` added to unify contracts creation

- the following community related path processors added:
- `CommunityBurnProcessor`
- `CommunityDeployAssetsProcessor`
- `CommunityDeployCollectiblesProcessor`
- `CommunityDeployOwnerTokenProcessor`
- `CommunityMintTokensProcessor`
- `CommunityRemoteBurnProcessor`
- `CommunitySetSignerPubKeyProcessor`

- `SendType` extended with appropriate options

- added endpoints to duplicated `communitytokens` api:
- `StoreDeployedCollectibles`
- `StoreDeployedOwnerToken`
- `StoreDeployedAssets`

- removed endpoints from duplicated `communitytokens` api:
- `DeployCollectibles`
- `DeployOwnerToken`
- `ReTrackOwnerTokenDeploymentTransaction`
- `DeployAssets`
- `DeployCollectiblesEstimate`
- `DeployAssetsEstimate`
- `DeployOwnerTokenEstimate`
- `EstimateMintTokens`
- `EstimateRemoteBurn`
- `EstimateBurn`
- `EstimateSetSignerPubKey`
- `NewOwnerTokenInstance`
- `NewCommunityTokenDeployerInstance`
- `NewCommunityOwnerTokenRegistryInstance`
- `NewCollectiblesInstance`
- `NewAssetsInstance`
- `MintTokens`
- `RemoteBurn`
- `GetCollectiblesContractInstance`
- `GetAssetContractInstance`
- `Burn`
- `SetSignerPubKey`

- `Path` type extended with new property:
- `UsedContractAddress` - an address of the contract that will be used for the transaction
2025-01-30 14:56:13 +01:00

74 lines
2.7 KiB
Go

package requests
import (
"math/big"
"testing"
"github.com/stretchr/testify/require"
"github.com/ethereum/go-ethereum/common"
"github.com/status-im/status-go/services/wallet/bigint"
)
func TestDeploymentParameters(t *testing.T) {
var testCases = []struct {
name string
parameters DeploymentParameters
isError bool
}{
{
name: "emptyName",
parameters: DeploymentParameters{"", "SYMBOL", &bigint.BigInt{Int: big.NewInt(int64(123))}, false, false, false, "", common.Address{}, common.Address{}, "", "", nil, "", 0},
isError: true,
},
{
name: "emptySymbol",
parameters: DeploymentParameters{"NAME", "", &bigint.BigInt{Int: big.NewInt(123)}, false, false, false, "", common.Address{}, common.Address{}, "", "", nil, "", 0},
isError: true,
},
{
name: "negativeSupply",
parameters: DeploymentParameters{"NAME", "SYM", &bigint.BigInt{Int: big.NewInt(-123)}, false, false, false, "", common.Address{}, common.Address{}, "", "", nil, "", 0},
isError: true,
},
{
name: "zeroSupply",
parameters: DeploymentParameters{"NAME", "SYM", &bigint.BigInt{Int: big.NewInt(0)}, false, false, false, "", common.Address{}, common.Address{}, "", "", nil, "", 0},
isError: false,
},
{
name: "negativeSupplyAndInfinite",
parameters: DeploymentParameters{"NAME", "SYM", &bigint.BigInt{Int: big.NewInt(-123)}, true, false, false, "", common.Address{}, common.Address{}, "", "", nil, "", 0},
isError: false,
},
{
name: "supplyGreaterThanMax",
parameters: DeploymentParameters{"NAME", "SYM", &bigint.BigInt{Int: big.NewInt(maxSupply + 1)}, false, false, false, "", common.Address{}, common.Address{}, "", "", nil, "", 0},
isError: true,
},
{
name: "supplyIsMax",
parameters: DeploymentParameters{"NAME", "SYM", &bigint.BigInt{Int: big.NewInt(maxSupply)}, false, false, false, "", common.Address{}, common.Address{}, "", "", nil, "", 0},
isError: false,
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
err := tc.parameters.Validate(false)
if tc.isError {
require.Error(t, err)
} else {
require.NoError(t, err)
}
})
}
notInfiniteSupplyParams := DeploymentParameters{"NAME", "SYM", &bigint.BigInt{Int: big.NewInt(123)}, false, false, false, "", common.Address{}, common.Address{}, "", "", nil, "", 0}
requiredSupply := big.NewInt(123)
require.Equal(t, notInfiniteSupplyParams.GetSupply(), requiredSupply)
infiniteSupplyParams := DeploymentParameters{"NAME", "SYM", &bigint.BigInt{Int: big.NewInt(123)}, true, false, false, "", common.Address{}, common.Address{}, "", "", nil, "", 0}
requiredSupply = infiniteSupplyParams.GetInfiniteSupply()
require.Equal(t, infiniteSupplyParams.GetSupply(), requiredSupply)
}