Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions clients/iota-go/iotago/programmable_transaction_builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,19 @@ import (
bcs "github.com/iotaledger/bcs-go"
)

func TestMain(m *testing.M) {
l1starter.TestMain(m)
}

func TestPTBMoveCall(t *testing.T) {
l1starter.TestLocal()
if l1starter.IsSimulatorConfigured() {
t.Skip("test does not work with simulator")
}
t.Run(
"access_multiple_return_values_from_move_func", func(t *testing.T) {
client := l1starter.Instance().L1Client()
sender := iotatest.MakeSignerWithFunds(0, l1starter.Instance().FaucetURL(), l1starter.Instance().APIURL())
sender := iotatest.MakeSigner(0)
require.NoError(t, client.RequestFundsFromFaucet(t.Context(), sender.Address()))

senderAddr := sender.Address()
txnBytes, err := client.Publish(
Expand Down Expand Up @@ -105,11 +112,16 @@ func TestPTBMoveCall(t *testing.T) {
}

func TestPTBPayIota(t *testing.T) {
l1starter.TestLocal()
if l1starter.IsSimulatorConfigured() {
t.Skip("test does not work with simulator")
}
client := l1starter.Instance().L1Client()
sender := iotatest.MakeSignerWithFunds(0, l1starter.Instance().FaucetURL(), l1starter.Instance().APIURL())
recipient1 := iotatest.MakeSignerWithFunds(1, l1starter.Instance().FaucetURL(), l1starter.Instance().APIURL())
recipient2 := iotatest.MakeSignerWithFunds(2, l1starter.Instance().FaucetURL(), l1starter.Instance().APIURL())
sender := iotatest.MakeSigner(0)
require.NoError(t, client.RequestFundsFromFaucet(t.Context(), sender.Address()))
recipient1 := iotatest.MakeSigner(1)
require.NoError(t, client.RequestFundsFromFaucet(t.Context(), recipient1.Address()))
recipient2 := iotatest.MakeSigner(2)
require.NoError(t, client.RequestFundsFromFaucet(t.Context(), recipient2.Address()))

senderAddr3 := sender.Address()
recipient1Addr := recipient1.Address()
Expand Down
15 changes: 3 additions & 12 deletions clients/iota-go/iotatest/faucet.go
Original file line number Diff line number Diff line change
@@ -1,26 +1,17 @@
package iotatest

import (
"context"

"github.com/iotaledger/wasp/v2/clients/iota-go/iotasigner"
"github.com/iotaledger/wasp/v2/clients/iotagraphql"
"github.com/iotaledger/wasp/v2/packages/testutil/testkey"
)

func MakeSignerWithFunds(index int, faucetURL, apiURL string) iotasigner.Signer {
return MakeSignerWithFundsFromSeed(testkey.NewTestSeedBytes(), index, faucetURL, apiURL)
func MakeSigner(index int) iotasigner.Signer {
return MakeSignerFromSeed(testkey.NewTestSeedBytes(), index)
}

func MakeSignerWithFundsFromSeed(seed []byte, index int, faucetURL, apiURL string) iotasigner.Signer {
func MakeSignerFromSeed(seed []byte, index int) iotasigner.Signer {
keySchemeFlag := iotasigner.KeySchemeFlagDefault

// there are only 256 different signers can be generated
signer := iotasigner.NewSignerByIndex(seed, keySchemeFlag, index)

client := iotagraphql.NewGraphQLClient(apiURL, faucetURL)
if err := client.RequestFundsFromFaucet(context.Background(), signer.Address()); err != nil {
panic(err)
}
return signer
}
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,10 @@ func TestPay(t *testing.T) {
func TestPayAllIota(t *testing.T) {
t.Skip("FIXME there is only 1 coin object, because there is only 1 coin object returned from faucet")
client := l1starter.Instance().L1Client()
signer := iotatest.MakeSignerWithFunds(0, l1starter.Instance().FaucetURL(), l1starter.Instance().APIURL())
recipient := iotatest.MakeSignerWithFunds(1, l1starter.Instance().FaucetURL(), l1starter.Instance().APIURL())
signer := iotatest.MakeSigner(0)
require.NoError(t, client.RequestFundsFromFaucet(t.Context(), signer.Address()))
recipient := iotatest.MakeSigner(1)
require.NoError(t, client.RequestFundsFromFaucet(t.Context(), recipient.Address()))

limit := int(3)
coinPages, err := client.GetCoins(
Expand Down Expand Up @@ -242,7 +244,8 @@ func TestPublish(t *testing.T) {
client := l1starter.Instance().L1Client()
// Use the faucet URL from the running node (LoadConfig() leaves it empty when using the local testnode).
// Use the waiting version to ensure coins are visible before proceeding.
signer := iotatest.MakeSignerWithFunds(0, l1starter.Instance().FaucetURL(), l1starter.Instance().APIURL())
signer := iotatest.MakeSigner(0)
require.NoError(t, client.RequestFundsFromFaucet(t.Context(), signer.Address()))

testcoinBytecode := contracts.Testcoin()

Expand Down
Loading