Skip to content

Commit f2fb043

Browse files
Merge pull request #80 from iulianpascalau/removes-crypto-payments-service
Removed the crypto payments service
2 parents 1f044bf + abe781d commit f2fb043

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+78
-6241
lines changed

Jenkinsfile-crypto-prod

Lines changed: 0 additions & 24 deletions
This file was deleted.

Jenkinsfile-crypto-staging

Lines changed: 0 additions & 24 deletions
This file was deleted.
File renamed without changes.

go.mod

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ toolchain go1.24.11
66

77
require (
88
github.com/dchest/captcha v1.1.0
9-
github.com/gin-gonic/gin v1.10.0
109
github.com/golang-jwt/jwt/v5 v5.3.0
10+
github.com/iulianpascalau/mx-crypto-payments v1.0.5
1111
github.com/joho/godotenv v1.5.1
1212
github.com/mattn/go-sqlite3 v1.14.33
1313
github.com/multiversx/mx-chain-core-go v1.4.1
@@ -50,6 +50,7 @@ require (
5050
github.com/gin-contrib/cors v1.6.0 // indirect
5151
github.com/gin-contrib/pprof v1.4.0 // indirect
5252
github.com/gin-contrib/sse v0.1.0 // indirect
53+
github.com/gin-gonic/gin v1.10.0 // indirect
5354
github.com/go-logr/logr v1.4.2 // indirect
5455
github.com/go-logr/stdr v1.2.2 // indirect
5556
github.com/go-ole/go-ole v1.2.6 // indirect

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,8 @@ github.com/ipfs/go-test v0.0.4 h1:DKT66T6GBB6PsDFLoO56QZPrOmzJkqU1FZH5C9ySkew=
268268
github.com/ipfs/go-test v0.0.4/go.mod h1:qhIM1EluEfElKKM6fnWxGn822/z9knUGM1+I/OAQNKI=
269269
github.com/ipld/go-ipld-prime v0.21.0 h1:n4JmcpOlPDIxBcY037SVfpd1G+Sj1nKZah0m6QH9C2E=
270270
github.com/ipld/go-ipld-prime v0.21.0/go.mod h1:3RLqy//ERg/y5oShXXdx5YIp50cFGOanyMctpPjsvxQ=
271+
github.com/iulianpascalau/mx-crypto-payments v1.0.5 h1:VuIssbSGLPvz9LDdtWVyF8qUMtl4ea7kgByra0epZAg=
272+
github.com/iulianpascalau/mx-crypto-payments v1.0.5/go.mod h1:4/NVijzrXB9NswwfiG8QSV4KkolilWOCjcxIhpVFSUw=
271273
github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus=
272274
github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc=
273275
github.com/jbenet/go-cienv v0.1.0/go.mod h1:TqNnHUmJgXau0nCzC7kXWeotg3J9W34CUv5Djy1+FlA=
Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package _go
1+
package integrationTests
22

33
import (
44
"context"
@@ -8,23 +8,30 @@ import (
88
"testing"
99
"time"
1010

11-
"github.com/iulianpascalau/mx-epoch-proxy-go/integrationTests/go/framework"
11+
cryptoPaymentsFramework "github.com/iulianpascalau/mx-crypto-payments/integrationTests/framework"
12+
"github.com/iulianpascalau/mx-epoch-proxy-go/integrationTests/framework"
1213
"github.com/multiversx/mx-chain-core-go/data/transaction"
14+
logger "github.com/multiversx/mx-chain-logger-go"
1315
"github.com/stretchr/testify/require"
1416
)
1517

18+
var log = logger.GetOrCreate("integrationTests")
19+
1620
func TestCreateFreeUserAndCreateKeyAndTestRequestsAreThrottledThenSwitchToPremium(t *testing.T) {
1721
if !framework.IsChainSimulatorIsRunning() {
1822
t.Skip("No chain simulator instance running found. Skipping slow test")
1923
}
24+
25+
framework.EnsureTestContracts(t)
26+
2027
proxyService := framework.NewProxyService(t)
21-
cryptoPaymentService := framework.NewCryptoPaymentService(t)
28+
cryptoPaymentService := cryptoPaymentsFramework.NewCryptoPaymentService(t)
2229

2330
ctx, cancel := context.WithCancel(context.Background())
2431
defer cancel()
2532

2633
proxyService.Setup(ctx)
27-
cryptoPaymentService.Setup(ctx, 100)
34+
cryptoPaymentService.Setup(ctx, 100, framework.GetContractPath("credits"))
2835

2936
defer proxyService.TearDown()
3037
defer cryptoPaymentService.TearDown()
@@ -87,7 +94,7 @@ func TestCreateFreeUserAndCreateKeyAndTestRequestsAreThrottledThenSwitchToPremiu
8794
// Value: 0.5 EGLD = 0.5 * 10^18 = 500000000000000000
8895
value := "500000000000000000"
8996

90-
receiverAddr := framework.NewMvxAddressFromBech32(t, session.GetDepositAddress())
97+
receiverAddr := cryptoPaymentsFramework.NewMvxAddressFromBech32(t, session.GetDepositAddress())
9198

9299
// Send Tx
93100
hash, _, status := cryptoPaymentService.ChainSimulator.SendTx(ctx, senderSk, receiverAddr, value, 500000, []byte{})

integrationTests/go/framework/chainSimulatorWrapper.go renamed to integrationTests/framework/chainSimulatorWrapper.go

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"testing"
1111
"time"
1212

13+
cryptoPaymentsFramework "github.com/iulianpascalau/mx-crypto-payments/integrationTests/framework"
1314
"github.com/multiversx/mx-chain-core-go/core"
1415
"github.com/multiversx/mx-chain-core-go/core/pubkeyConverter"
1516
apiCore "github.com/multiversx/mx-chain-core-go/data/api"
@@ -44,9 +45,10 @@ const (
4445
)
4546

4647
var (
47-
log = logger.GetOrCreate("integrationTests")
48-
signer = &singlesig.Ed25519Signer{}
49-
keyGenerator = signing.NewKeyGenerator(ed25519.NewEd25519())
48+
log = logger.GetOrCreate("integrationTests")
49+
signer = &singlesig.Ed25519Signer{}
50+
keyGenerator = signing.NewKeyGenerator(ed25519.NewEd25519())
51+
addressPubkeyConverter, _ = pubkeyConverter.NewBech32PubkeyConverter(32, "erd")
5052
)
5153

5254
// ESDTSupply represents the DTO that holds the supply values for a token
@@ -132,7 +134,7 @@ func (instance *chainSimulatorWrapper) GetNetworkAddress() string {
132134
}
133135

134136
// DeploySC will deploy the provided smart contract and return its address
135-
func (instance *chainSimulatorWrapper) DeploySC(ctx context.Context, wasmFilePath string, ownerSK []byte, gasLimit uint64, parameters []string) (*MvxAddress, string, *data.TransactionOnNetwork) {
137+
func (instance *chainSimulatorWrapper) DeploySC(ctx context.Context, wasmFilePath string, ownerSK []byte, gasLimit uint64, parameters []string) (*cryptoPaymentsFramework.MvxAddress, string, *data.TransactionOnNetwork) {
136138
networkConfig, err := instance.proxyInstance.GetNetworkConfig(ctx)
137139
require.Nil(instance.TB, err)
138140

@@ -164,11 +166,11 @@ func (instance *chainSimulatorWrapper) DeploySC(ctx context.Context, wasmFilePat
164166
require.Nil(instance, err)
165167
require.Equal(instance, transaction.TxStatusSuccess, txStatus, fmt.Sprintf("tx hash: %s,\n tx: %s", hash, string(jsonData)))
166168

167-
return NewMvxAddressFromBech32(instance.TB, txResult.Logs.Events[0].Address), hash, txResult
169+
return cryptoPaymentsFramework.NewMvxAddressFromBech32(instance.TB, txResult.Logs.Events[0].Address), hash, txResult
168170
}
169171

170172
// UpgradeSC will upgrade the provided smart contract
171-
func (instance *chainSimulatorWrapper) UpgradeSC(ctx context.Context, scAddress *MvxAddress, wasmFilePath string, ownerSK []byte, gasLimit uint64, parameters []string) (string, *data.TransactionOnNetwork) {
173+
func (instance *chainSimulatorWrapper) UpgradeSC(ctx context.Context, scAddress *cryptoPaymentsFramework.MvxAddress, wasmFilePath string, ownerSK []byte, gasLimit uint64, parameters []string) (string, *data.TransactionOnNetwork) {
172174
networkConfig, err := instance.proxyInstance.GetNetworkConfig(ctx)
173175
require.Nil(instance.TB, err)
174176

@@ -253,12 +255,12 @@ func (instance *chainSimulatorWrapper) GenerateBlocksUntilTxProcessed(ctx contex
253255
}
254256

255257
// ScCall will make the provided sc call
256-
func (instance *chainSimulatorWrapper) ScCall(ctx context.Context, senderSK []byte, contract *MvxAddress, value string, gasLimit uint64, function string, parameters []string) (string, *data.TransactionOnNetwork, transaction.TxStatus) {
258+
func (instance *chainSimulatorWrapper) ScCall(ctx context.Context, senderSK []byte, contract *cryptoPaymentsFramework.MvxAddress, value string, gasLimit uint64, function string, parameters []string) (string, *data.TransactionOnNetwork, transaction.TxStatus) {
257259
return instance.SendTx(ctx, senderSK, contract, value, gasLimit, createTxData(function, parameters))
258260
}
259261

260262
// ScCallWithoutGenerateBlocks will make the provided sc call and do not trigger the generate blocks command
261-
func (instance *chainSimulatorWrapper) ScCallWithoutGenerateBlocks(ctx context.Context, senderSK []byte, contract *MvxAddress, value string, gasLimit uint64, function string, parameters []string) string {
263+
func (instance *chainSimulatorWrapper) ScCallWithoutGenerateBlocks(ctx context.Context, senderSK []byte, contract *cryptoPaymentsFramework.MvxAddress, value string, gasLimit uint64, function string, parameters []string) string {
262264
return instance.SendTxWithoutGenerateBlocks(ctx, senderSK, contract, value, gasLimit, createTxData(function, parameters))
263265
}
264266

@@ -271,7 +273,7 @@ func createTxData(function string, parameters []string) []byte {
271273
}
272274

273275
// SendTx will build and send a transaction
274-
func (instance *chainSimulatorWrapper) SendTx(ctx context.Context, senderSK []byte, receiver *MvxAddress, value string, gasLimit uint64, dataField []byte) (string, *data.TransactionOnNetwork, transaction.TxStatus) {
276+
func (instance *chainSimulatorWrapper) SendTx(ctx context.Context, senderSK []byte, receiver *cryptoPaymentsFramework.MvxAddress, value string, gasLimit uint64, dataField []byte) (string, *data.TransactionOnNetwork, transaction.TxStatus) {
275277
hash := instance.SendTxWithoutGenerateBlocks(ctx, senderSK, receiver, value, gasLimit, dataField)
276278
instance.GenerateBlocks(ctx, 1)
277279
txResult, txStatus := instance.GetTransactionResult(ctx, hash)
@@ -280,7 +282,7 @@ func (instance *chainSimulatorWrapper) SendTx(ctx context.Context, senderSK []by
280282
}
281283

282284
// SendTxWithoutGenerateBlocks will build and send a transaction without generating blocks
283-
func (instance *chainSimulatorWrapper) SendTxWithoutGenerateBlocks(ctx context.Context, senderSK []byte, receiver *MvxAddress, value string, gasLimit uint64, dataField []byte) string {
285+
func (instance *chainSimulatorWrapper) SendTxWithoutGenerateBlocks(ctx context.Context, senderSK []byte, receiver *cryptoPaymentsFramework.MvxAddress, value string, gasLimit uint64, dataField []byte) string {
284286
senderPK := instance.getPublicKey(senderSK)
285287
nonce, err := instance.getNonce(ctx, senderPK)
286288
require.Nil(instance, err)
@@ -289,7 +291,7 @@ func (instance *chainSimulatorWrapper) SendTxWithoutGenerateBlocks(ctx context.C
289291
}
290292

291293
// SendTxWithNonceWithoutGenerateBlocks will build a transaction with given nonce and send it without generating blocks
292-
func (instance *chainSimulatorWrapper) SendTxWithNonceWithoutGenerateBlocks(ctx context.Context, senderSK []byte, receiver *MvxAddress, nonce uint64, value string, gasLimit uint64, dataField []byte) string {
294+
func (instance *chainSimulatorWrapper) SendTxWithNonceWithoutGenerateBlocks(ctx context.Context, senderSK []byte, receiver *cryptoPaymentsFramework.MvxAddress, nonce uint64, value string, gasLimit uint64, dataField []byte) string {
293295
networkConfig, err := instance.proxyInstance.GetNetworkConfig(ctx)
294296
require.Nil(instance, err)
295297

@@ -337,7 +339,7 @@ func (instance *chainSimulatorWrapper) FundWallets(ctx context.Context, wallets
337339
}
338340

339341
// GetESDTBalance returns the balance of the esdt token for the provided address
340-
func (instance *chainSimulatorWrapper) GetESDTBalance(ctx context.Context, address *MvxAddress, token string) string {
342+
func (instance *chainSimulatorWrapper) GetESDTBalance(ctx context.Context, address *cryptoPaymentsFramework.MvxAddress, token string) string {
341343
tokenData, err := instance.proxyInstance.GetESDTTokenData(ctx, address, token, apiCore.AccountQueryOptions{
342344
OnFinalBlock: true,
343345
})
@@ -426,7 +428,7 @@ func computeTransactionSignature(senderSk []byte, tx *transaction.FrontendTransa
426428
// ExecuteVMQuery will try to execute a VM query and return the results
427429
func (instance *chainSimulatorWrapper) ExecuteVMQuery(
428430
ctx context.Context,
429-
scAddress *MvxAddress,
431+
scAddress *cryptoPaymentsFramework.MvxAddress,
430432
function string,
431433
hexParams []string,
432434
) [][]byte {
Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,18 @@ package framework
33
import (
44
"path/filepath"
55
"runtime"
6+
"testing"
7+
8+
cryptoPaymentsFramework "github.com/iulianpascalau/mx-crypto-payments/integrationTests/framework"
9+
"github.com/stretchr/testify/require"
610
)
711

8-
// PaymentGasLimit is the gas limit for the payment transaction
9-
const PaymentGasLimit = 50000
12+
// GetProxyRootPath returns the absolute path to the proxy service root path
13+
func GetProxyRootPath(templateFile string) string {
14+
currentDir := traverse("integrationTests")
1015

11-
// CallGasLimit is the gas limit for a SC call
12-
const CallGasLimit = 3000000
16+
return filepath.Join(currentDir, "services", "proxy", templateFile)
17+
}
1318

1419
// GetContractPath returns the absolute path to the wasm file
1520
func GetContractPath(contractName string) string {
@@ -18,11 +23,13 @@ func GetContractPath(contractName string) string {
1823
return filepath.Join(currentDir, "contracts", contractName, contractName+".wasm")
1924
}
2025

21-
// GetProxyRootPath returns the absolute path to the proxy service root path
22-
func GetProxyRootPath(templateFile string) string {
23-
currentDir := traverse("integrationTests")
26+
// EnsureTestContracts test if the contracts are present in the project, if not, download them
27+
func EnsureTestContracts(tb testing.TB) {
28+
root := traverse("integrationTests")
29+
extractTarget := filepath.Join(root, "contracts")
2430

25-
return filepath.Join(currentDir, "services", "proxy", templateFile)
31+
err := cryptoPaymentsFramework.EnsureContractCredits(cryptoPaymentsFramework.ContractCreditsURL, extractTarget)
32+
require.NoError(tb, err)
2633
}
2734

2835
func traverse(upToDir string) string {

integrationTests/go/framework/interface.go renamed to integrationTests/framework/interface.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ package framework
33
import (
44
"context"
55

6-
"github.com/iulianpascalau/mx-epoch-proxy-go/services/crypto-payment/factory"
7-
"github.com/iulianpascalau/mx-epoch-proxy-go/services/crypto-payment/process"
6+
"github.com/iulianpascalau/mx-crypto-payments/factory"
7+
"github.com/iulianpascalau/mx-crypto-payments/process"
88
proxyApi "github.com/iulianpascalau/mx-epoch-proxy-go/services/proxy/api"
99
proxyFactory "github.com/iulianpascalau/mx-epoch-proxy-go/services/proxy/factory"
1010
"github.com/multiversx/mx-chain-core-go/data/api"

0 commit comments

Comments
 (0)