Skip to content

Latest commit

 

History

History
390 lines (272 loc) · 11.2 KB

test-xdc-chain.md

File metadata and controls

390 lines (272 loc) · 11.2 KB

Test xdc chain

Test hummingbot gateway API with xdc chain

Setup enviroment

  • Setup enviroment according to instruction before test.
  • Mint some test tokens to your test account.

Test cases

1. Query gateway status

# curl -s -X GET -k --key ${GATEWAY_KEY} --cert ${GATEWAY_CERT} ${SERVER} | jq
https --print=b ${SERVER}

1669875962368

2. Query network config

# curl -s -X GET -k --key $GATEWAY_KEY --cert $GATEWAY_CERT "${SERVER}/network/config" | jq
https --print=b ${SERVER}/network/config

1669876075182

3. Query connectors

# curl -s -X GET -k --key ${GATEWAY_KEY} --cert ${GATEWAY_CERT} ${SERVER}/connectors | jq
https --print=b ${SERVER}/connectors

1669878972967

4. Query network status

xinfin

# curl -s -X GET -k --key $GATEWAY_KEY --cert $GATEWAY_CERT "${SERVER}/network/status?chain=xdc&network=xinfin" | jq
https --print=b ${SERVER}/network/status chain==xdc network==xinfin

1679628870454

apothem

# curl -s -X GET -k --key $GATEWAY_KEY --cert $GATEWAY_CERT "${SERVER}/network/status?chain=xdc&network=apothem" | jq
https --print=b ${SERVER}/network/status chain==xdc network==apothem

1679628964147

all networks

# curl -s -X GET -k --key $GATEWAY_KEY --cert "$GATEWAY_CERT" "${SERVER}/network/status" | jq
https --print=b ${SERVER}/network/status

1679629021834

5. Fetch token list

xinfin

# curl -s -X GET -k --key $GATEWAY_KEY --cert $GATEWAY_CERT "${SERVER}/network/tokens?chain=xdc&network=xinfin" | jq
https --print=b ${SERVER}/network/tokens chain==xdc network==xinfin

1669876730976

apothem

# curl -s -X GET -k --key $GATEWAY_KEY --cert $GATEWAY_CERT "${SERVER}/network/tokens?chain=xdc&network=apothem" | jq
https --print=b ${SERVER}/network/tokens chain==xdc network==apothem

1669876794725

6. Query transaction

6.1 If use curl

xinfin

curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "${HEADER}"  "${SERVER}/network/poll" -d '{
    "chain": "xdc",
    "network": "xinfin",
    "txHash": "0xf49e741720e3f6c464e7bfbdcaefddb6f9a4cc39d4b367476727e95be735b350"
}' | jq

apothem

curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "${HEADER}"  "${SERVER}/network/poll" -d '{
    "chain": "xdc",
    "network": "apothem",
    "txHash": "0x1114601d48ebc3afa5e06af13e759560e74b3d5d1837d951919bc57727a623dd"
}' | jq

6.2 If use httpie

xinfin

https --print=b POST ${SERVER}/network/poll chain=xdc network=xinfin txHash=0xf49e741720e3f6c464e7bfbdcaefddb6f9a4cc39d4b367476727e95be735b350

1669879304138

apothem

https --print=b POST ${SERVER}/network/poll chain=xdc network=apothem txHash=0x1114601d48ebc3afa5e06af13e759560e74b3d5d1837d951919bc57727a623dd

1669877250971

7 Add private key

The length of private key is 67 characters with xdc prefix or 66 characters with 0x prefix, such as:

  • xdc prefix: xdc0123456789012345678901234567890123456789012345678901234567890123
  • 0x prefix: 0x0123456789012345678901234567890123456789012345678901234567890123

We will use xdc-prefix in below tests.

# export XDC_PRIVATE_KEY="xdc0123456789012345678901234567890123456789012345678901234567890123"
export XDC_PRIVATE_KEY="<YOUR_XDC_PRIVATE_KEY>"

image

7.1 If use curl

xinfin

curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "${HEADER}" "${SERVER}/wallet/add" -d '{
    "privateKey": "'"${XDC_PRIVATE_KEY}"'",
    "chain": "xdc",
    "network":"xinfin"
}' | jq

apothem

curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "${HEADER}" "${SERVER}/wallet/add" -d '{
    "privateKey": "'"${XDC_PRIVATE_KEY}"'",
    "chain": "xdc",
    "network":"apothem"
}' | jq

7.2 If use httpie

xinfin

https --print=b ${SERVER}/wallet/add privateKey=${XDC_PRIVATE_KEY} chain=xdc network=xinfin

1669878351454

apothem

https --print=b ${SERVER}/wallet/add privateKey=${XDC_PRIVATE_KEY} chain=xdc network=apothem

1669878845008

8. Query token balances

8.1 If use curl

xinfin

curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "${HEADER}" "${SERVER}/network/balances" -d '{
    "chain": "xdc",
    "network": "xinfin",
    "address": "'"${XDC_ADDRESS}"'",
    "tokenSymbols": ["XDC","WXDC"]
}' | jq

apothem

curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "${HEADER}" "${SERVER}/network/balances" -d '{
    "chain": "xdc",
    "network": "apothem",
    "address": "'"${XDC_ADDRESS}"'",
    "tokenSymbols": ["XDC","WXDC", "DAI", "WBTC2", "YFI2", "MKR2", "AAVE2", "UNI2", "USDC2"]
}' | jq

8.2 If use httpie

xinfin

https --print=b POST ${SERVER}/network/balances chain=xdc network=xinfin \
address=${XDC_ADDRESS} tokenSymbols:='["XDC", "WXDC"]'

1669879947119

apothem

https --print=b POST ${SERVER}/network/balances chain=xdc network=apothem \
address=${XDC_ADDRESS} tokenSymbols:='["XDC", "WXDC", "WBTC2", "YFI2", "MKR2", "USDC2"]'

1669879997687

9. Query account nonce

9.1 If use curl

xinfin

curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "${HEADER}" "${SERVER}/evm/nonce" -d '{
    "chain": "xdc",
    "network": "xinfin",
    "address":"'"$XDC_ADDRESS"'"
}' | jq

apothem

curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "${HEADER}" "${SERVER}/evm/nonce" -d '{
    "chain": "xdc",
    "network": "apothem",
    "address":"'"$XDC_ADDRESS"'"
}' | jq

9.2 If use httpie

xinfin

https --print=b POST ${SERVER}/evm/nonce chain=xdc network=xinfin address=${XDC_ADDRESS}

1669880139820

apothem

https --print=b POST ${SERVER}/evm/nonce chain=xdc network=apothem address=${XDC_ADDRESS}

1669880196463

10. Query allowances

10.1 If use curl

xinfin

curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "${HEADER}" "${SERVER}/evm/allowances" -d '{
    "chain": "xdc",
    "network": "xinfin",
    "address": "'"$XDC_ADDRESS"'",
    "spender": "xdc41c0ad06c98951e9bf7172cd1d285c6e34537170",
    "tokenSymbols": ["WXDC", "SRX", "XTT", "xUSDT"]
}' | jq

apothem

curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "${HEADER}" "${SERVER}/evm/allowances" -d '{
    "chain": "xdc",
    "network": "apothem",
    "address": "'"$XDC_ADDRESS"'",
    "spender": "xdc41c0ad06c98951e9bf7172cd1d285c6e34537170",
    "tokenSymbols": ["WBTC2", "YFI2", "MKR2", "AAVE2", "UNI2", "USDC2"]
}' | jq

10.2 If use httpie

xinfin

https --print=b POST ${SERVER}/evm/allowances chain=xdc network=xinfin address=${XDC_ADDRESS} \
spender=xdc85f33E1242d87a875301312BD4EbaEe8876517BA tokenSymbols:='["WXDC", "SRX", "XTT", "xUSDT"]'

1669880604574

apothem

https --print=b POST ${SERVER}/evm/allowances chain=xdc network=apothem address=${XDC_ADDRESS} \
spender=xdc85f33E1242d87a875301312BD4EbaEe8876517BA tokenSymbols:='["WBTC2", "YFI2", "MKR2", "AAVE2", "UNI2", "USDC2"]'

1669880674424

11. Approve allowance

11.1 If use curl

xinfin

curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "${HEADER}" "${SERVER}/evm/approve" -d '{
    "chain": "xdc",
    "network": "xinfin",
    "address": "'"$XDC_ADDRESS"'",
    "spender": "xdc41c0ad06c98951e9bf7172cd1d285c6e34537170",
    "token": "SRX"
}' | jq

apothem

curl -s -X POST -k --key $GATEWAY_KEY --cert $GATEWAY_CERT -H "${HEADER}" "${SERVER}/evm/approve" -d '{
    "chain": "xdc",
    "network": "apothem",
    "address": "'"$XDC_ADDRESS"'",
    "spender": "xdc41c0ad06c98951e9bf7172cd1d285c6e34537170",
    "token": "USDC2"
}' | jq

11.2 If use httpie

xinfin

# query allowances
https --print=b POST ${SERVER}/evm/allowances chain=xdc network=xinfin address=${XDC_ADDRESS} \
spender=xdc41c0ad06c98951e9bf7172cd1d285c6e34537170 tokenSymbols:='["SRX"]'

# set allowances to maximum
https --print=h POST ${SERVER}/evm/approve chain=xdc network=xinfin address=${XDC_ADDRESS} \
spender=xdc41c0ad06c98951e9bf7172cd1d285c6e34537170 token=SRX

# query allowances
https --print=b POST ${SERVER}/evm/allowances chain=xdc network=xinfin address=${XDC_ADDRESS} \
spender=xdc41c0ad06c98951e9bf7172cd1d285c6e34537170 tokenSymbols:='["SRX"]'

1666773893275

apothem

# clear allowances
https --print=h POST ${SERVER}/evm/approve chain=xdc network=apothem address=${XDC_ADDRESS} \
spender=xdc41c0ad06c98951e9bf7172cd1d285c6e34537170 token=USDC2 amount=0

# query allowances
https --print=b POST ${SERVER}/evm/allowances chain=xdc network=apothem address=${XDC_ADDRESS} \
spender=xdc41c0ad06c98951e9bf7172cd1d285c6e34537170 tokenSymbols:='["USDC2"]'

# set allowances to maximum
https --print=h POST ${SERVER}/evm/approve chain=xdc network=apothem address=${XDC_ADDRESS} \
spender=xdc41c0ad06c98951e9bf7172cd1d285c6e34537170 token=USDC2

# query allowances
https --print=b POST ${SERVER}/evm/allowances chain=xdc network=apothem address=${XDC_ADDRESS} \
spender=xdc41c0ad06c98951e9bf7172cd1d285c6e34537170 tokenSymbols:='["USDC2"]'

1666773765723