This repository has been archived by the owner on Jan 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
jest and muck testing added to project for unit testing
- Loading branch information
dorbor
committed
Sep 22, 2022
1 parent
ef77c74
commit 211953a
Showing
9 changed files
with
6,171 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,4 +41,3 @@ app.listen( | |
) | ||
); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# XUMM-XRPL Proof of Concept | ||
|
||
This repo demonstrates a Proof of Concept application for sending offers to the XRPL Decentralised Exchange (DEX) using the XUMM app for authentication. | ||
|
||
## Installation | ||
|
||
The application itself is a node js application so make sure to have node js installed in your environment. To install the requirements run: | ||
|
||
```bash | ||
yarn install | ||
``` | ||
|
||
The script to demo the application is written in python. Ensure you have python3 installed in your (ideally virtual) environment and run: | ||
|
||
```bash | ||
pip install -r requirements.txt | ||
``` | ||
|
||
## Run the demo | ||
|
||
First you need to create a `.env` file in the root directory with the following keys: | ||
|
||
* `NODE_ENV`: Used by the node server. If this is set to 'development', middleware logging will be done. | ||
* `API_KEY`: XUMM Developer Application API Key. Used by the node server to communicate with XUMM. | ||
* `API_SECRET`: XUMM Developer Application API Secret. Used by the node server to communicate with XUMM. | ||
* `WALLET_ADDRESS`: Used by the python code to know which wallet to transact under. | ||
|
||
Then, open two terminals. In the first terminal run: | ||
|
||
```bash | ||
yarn dev | ||
``` | ||
|
||
This will start the development server which will respond to requests that our python script will send to it. | ||
|
||
In the second terminal run: | ||
|
||
```bash | ||
python -m scripts.poc_demo | ||
``` | ||
|
||
This will send two requests to our server. The first will open your default web browser displaying a QR code which you must scan with your XUMM app and sign the transaction to retrieve a user token. This user token will then be used in the second request in order to send a push notification to the user to sign the offer transaction that will be sent to the DEX instead of having them scan a QR code. Ensure your XUMM app has access to the wallet you are using to perform the transaction. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Connect to xumm sdk | ||
|
||
set 1) make sure you have yarn package manager install | ||
step 3) clone repo with: git clone (repo) | ||
step 3) in your terminal, run 'yarn install' // to istall all the require packages | ||
step 4) in your terminal, run 'yarn dev' | ||
|
||
|
||
step 5) use postman to submit data to the below routes | ||
|
||
localhost:4000/api/v1/xrp/test (for testing) | ||
whatever data you want to pass | ||
localhost:4000/api/v1/xrp/createdexoffer (create offer on xrpl lerger production server) | ||
json data | ||
|
||
{ | ||
"address": "---wallet address---", | ||
"weWant": { | ||
"currency": "currency", | ||
"value": "value" | ||
}, | ||
"weSpend": { | ||
"currency": "currency", | ||
"value": "value" | ||
} | ||
} | ||
|
||
|
||
1)get user token without cash transaction --> | ||
# visit : localhost:4000/api/v1/xrp/gettoken | ||
# you will get a qrcode, | ||
# scan to sign request | ||
# user token will be generated on the fly |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
const app = require('../app'); | ||
const request = require('supertest'); | ||
const axios = require('axios'); | ||
const { JsonWebTokenError } = require('jsonwebtoken'); | ||
|
||
jest.mock("axios") | ||
|
||
describe('xrp testing', () => { | ||
it('XRPL create dex offer', () => { | ||
const resp = "offer created sussefully on the xrpl lerger" | ||
axios.get.mockResolvedValue(resp) | ||
return expect(resp).toEqual(resp) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const request = require('supertest'); | ||
const axios = require('axios'); | ||
|
||
jest.mock("axios") | ||
|
||
describe('xrp testing', () => { | ||
|
||
it('Get User token ', () => { | ||
const userToken = {"user_token": "74d-2641f0398-8562-3782-24ffe3843c52" } | ||
axios.get.mockResolvedValue(userToken) | ||
return expect(userToken).toEqual(userToken) | ||
}) | ||
|
||
it('Send Xrp via Xumm wallet ', () => { | ||
const status = {"status": "xrp send successfully" } | ||
axios.post.mockResolvedValue(status) | ||
return expect(status).toEqual(status) | ||
}) | ||
}) |
Oops, something went wrong.