planetmint-go/util/machine_nft_test.go
Jürgen Eckel 4f5b1e5777
Multi validator setup in test cases (#333)
* Initializing rootDir of dao and machine keeper with the home path of the validator key material
* added Block height logging of context decorator
* removed SetRoot usage
* fixed data races of the attest machine go-routine
* reproduction of the issue
* fixed testing URL issue
* refactored the machine-nft functions/mock
* fixed keeper.param read-bug that increased the gas prices in an inconsistent way
* increased the validator number to 3 for all e2e tests
* added go routine to attest machine workflow

---------

Signed-off-by: Julian Strobl <jmastr@mailbox.org>
Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
Co-authored-by: Julian Strobl <jmastr@mailbox.org>
Co-authored-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
2024-03-05 11:37:01 +01:00

43 lines
1.5 KiB
Go

package util_test
import (
"context"
"testing"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/planetmint/planetmint-go/testutil/keeper"
"github.com/planetmint/planetmint-go/testutil/sample"
"github.com/planetmint/planetmint-go/util"
"github.com/planetmint/planetmint-go/util/mocks"
elements "github.com/rddl-network/elements-rpc"
elementsmocks "github.com/rddl-network/elements-rpc/utils/mocks"
"github.com/stretchr/testify/assert"
)
func TestRegisterNFT(t *testing.T) {
t.Parallel()
url := "https://testnet-assets.rddl.io/register_asset"
contract := `{"entity":{"domain":"testnet-assets.rddl.io"},"issuer_pubkey":"020000000000000000000000000000000000000000000000000000000000000000","machine_addr":"plmnt10mq5nj8jhh27z7ejnz2ql3nh0qhzjnfvy50877","name":"machine","precision":0,"version":0}`
asset := "0000000000000000000000000000000000000000000000000000000000000000"
goctx := context.Background()
util.RegisterAssetServiceHTTPClient = &mocks.MockClient{}
err := util.RegisterAsset(goctx, asset, contract, url)
assert.NoError(t, err)
}
func TestMachineNFTIssuance(t *testing.T) {
t.Parallel()
elements.Client = &elementsmocks.MockClient{}
util.RegisterAssetServiceHTTPClient = &mocks.MockClient{}
_, ctx := keeper.MachineKeeper(t)
sk, pk := sample.KeyPair()
machine := sample.Machine(pk, pk, sk, "")
goCtx := sdk.WrapSDKContext(ctx)
err := util.IssueMachineNFT(goCtx, &machine, "https", "testnet-asset.rddl.io", "/register_asset")
assert.NoError(t, err)
}