예제 #1
0
#!/usr/bin/env python3
"""Test for iden3/go-iden3/cmd/backupserver
"""

import json
import requests
import provoj

URL = "http://127.0.0.1:5001/api/unstable"
username = '******'
password = '******'
backup_data = 'this is the backup data'

T = provoj.NewTest("Backup")

R = requests.post(URL + "/register",
                  json={
                      'username': username,
                      'password': password
                  })
T.rStatus("register", R)

R = requests.post(URL + "/backup/upload",
                  json={
                      'username': username,
                      'password': password,
                      'backup': backup_data
                  })
T.rStatus("register", R)

R = requests.post(URL + "/backup/download",
예제 #2
0
#!/usr/bin/env python3
"""Test for kvartalo/relay
"""

import json
import requests
#  import datetime
import provoj

URL = "http://127.0.0.1:3000"
ADDR = "0xbc88fcc53af747D30F1e17729659001d1129ddd7"

T = provoj.NewTest("Relay")

R = requests.get(URL + "/balance/" + ADDR)
T.rStatus("get balanceOf", R)
jsonR = R.json()
print(jsonR)

R = requests.get(URL + "/tx/nonce/" + ADDR)
T.rStatus("get nonceOf", R)

R = requests.post(URL + "/tx", json={'a': 'b'})
T.rStatus("post tx", R)

T.printScores()
예제 #3
0
#!/usr/bin/env python3
"""notifications-server endpoints test
"""

import requests
import provoj

URL = "http://127.0.0.1:10000/api/unstable"

t = provoj.NewTest("notifications-server")

r = requests.get(URL + "/")
t.rStatus("get info", r)

idaddr0 = "0x47a2b2353f1a55e4c975b742a7323c027160b4e3"
idaddr1 = "0xd9d6800a1b20ceebef5420f878bbd915f8b4ed85"

r = requests.post(URL + "/notifications/" + idaddr0, json={"data": "notif00"})
t.rStatus("post notification to " + idaddr0, r)

#  i = 0
for i in range(18):
    notificationData = "notif" + str(i)
    r = requests.post(URL + "/notifications/" + idaddr0, json={"data": notificationData})
    r = requests.post(URL + "/notifications/" + idaddr1, json={"data": notificationData})

r = requests.post(URL + "/notifications", json={"idAddr": idaddr0})
t.rStatus("get notifications for " + idaddr0, r)

r = requests.post(URL + "/notifications?beforeid=1", json={"idAddr": idaddr0})
t.rStatus("get notifications for " + idaddr0, r)
예제 #4
0
import provoj
import requests

test1 = provoj.NewTest("testing some function")

a = "hello"
b = "world"
c = "hello"

test1.equal("comparing a and b", a, b)
test1.notequal("comparing a and b", a, b)

test1.equal("comparing a and c", a, c)

x = 2
y = 3
test1.bigger("comparing x and y", x, y)
test1.smaller("comparing x and y", x, y)

test1.length("checking length", a, 2)
test1.length("checking length", a, 5)

animals = ["cat", "dog", "racoon"]
test1.length("checking the length of the array animals", animals, 3)

test1.printScores()

t2 = provoj.NewTest("Testing some websites")

r = requests.get("https://www.github.com")
t2.rStatus("get github", r)
예제 #5
0
#!/usr/bin/env python3
"""discovery-node endpoints test
"""

import requests
import provoj
import time

URL0 = "http://127.0.0.1:3000"
URL1 = "http://127.0.0.1:4000"

t = provoj.NewTest("discovery-node")

r = requests.get(URL0 + "/")
t.rStatus("check root endpoint from Node0", r)
r = requests.get(URL1 + "/")
t.rStatus("check root endpoint from Node1", r)

id0 = {"idAddr": "0x47a2b2353f1a55e4c975b742a7323c027160b4e3"}

r = requests.post(URL0 + "/id", json=id0)
t.rStatus("post id0 (" + id0["idAddr"] + ") to Node0 ", r)

time.sleep(1)

# get the data from the id0, as the discovery-node don't have the id data, will ask for it over Pss Swarm network
r = requests.get(URL1 + "/id/" + id0["idAddr"])
t.rStatus("get id0 (" + id0["idAddr"] + ") from Node1 ", r)
jsonR = r.json()
print(jsonR)
예제 #6
0
#!/usr/bin/env python3
"""go-iden3/cmd/claimserver endpoints test
"""

import requests
import provoj

URL = "http://127.0.0.1:6000/api/unstable"

t = provoj.NewTest("claimserver")

r = requests.get(URL + "/root")
t.rStatus("get root", r)

aux = "0x" + str.encode(
    "asdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdfasdf").hex()
r = requests.post(URL + "/claims", json={"indexData": aux, "data": aux})
t.rStatus("post claim", r)
postClaimRes = r.json()

hi = "0x15a329f60308d935a9665bb922b36b3bbdd031260cab1a3cef027b0055dea55f"
r = requests.get(URL + "/claims/" + hi + "/proof")
t.rStatus("get claim proof by hi", r)
getClaimRes = r.json()

t.equal("postClaim response == getClaim response (proofClaim)", postClaimRes,
        getClaimRes)

t.printScores()
예제 #7
0
#!/usr/bin/env python3
"""Test endpoints for gogame
"""

import json
import requests
import provoj
import time

import os

os.system("mongo gogame --eval 'db.dropDatabase()'")

URL = "http://127.0.0.1:5000"

t = provoj.NewTest("gogame")

registerData = {
    "name": "user00",
    "password": "******",
    "email": "*****@*****.**",
}
r = requests.post(URL + "/register", json=registerData)
t.rStatus("post /register", r)
jsonR = r.json()
print(jsonR)

loginData = {
    "email": "*****@*****.**",
    "password": "******",
}
예제 #8
0
파일: test.py 프로젝트: iden3/tx-forwarder
#!/usr/bin/env python3
"""Test endpoints for iden3/tx-forwarder
"""

import json
import requests
import provoj
import time

URL = "http://127.0.0.1:11000/api/unstable"

addr = "0xbc88fcc53af747D30F1e17729659001d1129ddd7"

t = provoj.NewTest("tx-forwarder")

# Sample contract call
data = str.encode("test")
r = requests.post(URL + "/tx/sample",
                  json={
                      'addr': addr,
                      'dataHex': data.hex()
                  })
t.rStatus("post forward tx", r)
jsonR = r.json()
print(jsonR)

# FullVerifier contract forward
zkpdata = {
    "a": [
        "0x14d6994cfd7b91d300be287ca6bbd80592ad8bdd097b3f05e15addc04115a20a",
        "0x2780097a84c727a3fba03f30c7931137fbe04efdabdabf726d7e067238ff39e8"
예제 #9
0
'''
    this script uses requests and provoj
    provoj is a simple library to test endpoints of an API RESTful
    provoj can be downloaded using: pip install provoj
    provoj repository: https://github.com/arnaucode/provoj

    To run this test, just need to run:
    python test.py
'''
import provoj
import requests

test = provoj.NewTest("testing padArchiver API Server")

url = "http://127.0.0.1:3080"

jsonData = {
    "link": "http://board.net/p/pad1",
    "dir": "Group1",
    "title": "Pad1"
}
r = requests.post(url + "/repos/repo01/pad", json=jsonData)
test.rStatus("POST add new pad", r)
print(r.json())

jsonData = {
    "link": "http://board.net/p/pad2",
    "dir": "Group2",
    "title": "Pad2"
}
r = requests.post(url + "/repos/repo01/pad", json=jsonData)