decred.org/dcrdex@v1.0.5/client/asset/polygon/multirpc_live_test.go (about)

     1  //go:build rpclive
     2  
     3  package polygon
     4  
     5  import (
     6  	"context"
     7  	"os"
     8  	"testing"
     9  
    10  	"decred.org/dcrdex/client/asset/eth"
    11  	"decred.org/dcrdex/dex"
    12  )
    13  
    14  const (
    15  	alphaHTTPPort = "48296"
    16  	alphaWSPort   = "34983"
    17  )
    18  
    19  var mt *eth.MRPCTest
    20  
    21  func TestMain(m *testing.M) {
    22  	ctx, shutdown := context.WithCancel(context.Background())
    23  	mt = eth.NewMRPCTest(ctx, ChainConfig, NetworkCompatibilityData, "polygon")
    24  	doIt := func() int {
    25  		defer shutdown()
    26  		return m.Run()
    27  	}
    28  	os.Exit(doIt())
    29  }
    30  
    31  func TestHTTP(t *testing.T) {
    32  	mt.TestHTTP(t, alphaHTTPPort)
    33  }
    34  
    35  func TestWS(t *testing.T) {
    36  	mt.TestWS(t, alphaWSPort)
    37  }
    38  
    39  func TestWSTxLogs(t *testing.T) {
    40  	mt.TestWSTxLogs(t, alphaWSPort)
    41  }
    42  
    43  func TestSimnetMultiRPCClient(t *testing.T) {
    44  	mt.TestSimnetMultiRPCClient(t, alphaWSPort, alphaHTTPPort)
    45  }
    46  
    47  func TestMonitorTestnet(t *testing.T) {
    48  	mt.TestMonitorNet(t, dex.Testnet)
    49  }
    50  
    51  func TestMonitorMainnet(t *testing.T) {
    52  	mt.TestMonitorNet(t, dex.Mainnet)
    53  }
    54  
    55  func TestRPCMainnet(t *testing.T) {
    56  	mt.TestRPC(t, dex.Mainnet)
    57  }
    58  
    59  func TestRPCTestnet(t *testing.T) {
    60  	mt.TestRPC(t, dex.Testnet)
    61  }
    62  
    63  func TestFreeServers(t *testing.T) {
    64  	// https://www.alchemy.com/chain-connect/chain/polygon-pos
    65  	// https://chainlist.org/?search=Polygon+Mainnet
    66  	freeServers := []string{
    67  		// Passing
    68  		"https://1rpc.io/matic",
    69  		"https://rpc.ankr.com/polygon",
    70  		"https://polygon.blockpi.network/v1/rpc/public",
    71  		"https://polygon.llamarpc.com",
    72  		"https://endpoints.omniatech.io/v1/matic/mainnet/public",
    73  		"https://rpc-mainnet.matic.quiknode.pro",
    74  		"https://gateway.tenderly.co/public/polygon",
    75  		// Failing
    76  		"https://matic-mainnet-full-rpc.bwarelabs.com", // connect error: failed to connect to even a single provider among: bwarelabs.com
    77  		"https://polygon.api.onfinality.io/public",     // "BalanceAt" error: Too Many Requests, Please apply an OnFinality API key or contact us to receive a higher rate limit
    78  		"https://poly-rpc.gateway.pokt.network",        // connect error: failed to connect to even a single provider among: pokt.network
    79  		"https://polygon-rpc.com",                      // "TransactionReceipt" error: not found
    80  		"https://polygon.meowrpc.com",                  // "TransactionReceipt" error: not found
    81  		"wss://polygon.drpc.org",                       // "TransactionReceipt" error: Unable to perform request
    82  		"https://polygon.rpc.blxrbdn.com",              // "TransactionReceipt" error: not found
    83  		"https://g.w.lavanet.xyz:443/gateway/polygon1/rpc-http/f7ee0000000000000000000000000000", // "TransactionReceipt" error: not found
    84  		"https://rpc-mainnet.matic.network",                     // connect error: failed to connect to even a single provider among: matic.network
    85  		"wss://polygon-bor-rpc.publicnode.com",                  // "TransactionReceipt" error: not found
    86  		"https://public.stackup.sh/api/v1/node/polygon-mainnet", // "TransactionReceipt" error: not found
    87  		"https://matic-mainnet.chainstacklabs.com",              // connect error: failed to connect to even a single provider among: chainstacklabs.com
    88  
    89  	}
    90  	mt.TestFreeServers(t, freeServers, dex.Mainnet)
    91  }
    92  
    93  func TestFreeTestnetServers(t *testing.T) {
    94  	// https://chainlist.org/chain/80002
    95  	// PASSING 24 April 2024
    96  	freeServers := []string{
    97  		"https://rpc-amoy.polygon.technology",
    98  		"wss://polygon-amoy-bor-rpc.publicnode.com",
    99  		"https://polygon-amoy.blockpi.network/v1/rpc/public",
   100  	}
   101  	mt.TestFreeServers(t, freeServers, dex.Testnet)
   102  }
   103  
   104  func TestMainnetCompliance(t *testing.T) {
   105  	mt.TestMainnetCompliance(t)
   106  }
   107  
   108  func TestTestnetFees(t *testing.T) {
   109  	mt.FeeHistory(t, dex.Testnet, 3, 90)
   110  }
   111  
   112  func TestTestnetTipCaps(t *testing.T) {
   113  	mt.TipCaps(t, dex.Testnet)
   114  }
   115  
   116  func TestFees(t *testing.T) {
   117  	mt.FeeHistory(t, dex.Mainnet, 3, 365)
   118  }
   119  
   120  func TestTipCaps(t *testing.T) {
   121  	mt.TipCaps(t, dex.Mainnet)
   122  }
   123  
   124  func TestReceiptsHaveEffectiveGasPrice(t *testing.T) {
   125  	mt.TestReceiptsHaveEffectiveGasPrice(t)
   126  }