testing dshackle
This commit is contained in:
@@ -16,7 +16,10 @@ const options = {
|
||||
const packageDefinition = protoLoader.loadSync(PROTO_PATH, options);
|
||||
const emerald = grpc.loadPackageDefinition(packageDefinition).emerald
|
||||
|
||||
export function describe(url, ca, cert, key, handler) {
|
||||
|
||||
var id = 100
|
||||
|
||||
export function connect(url, ca, cert, key) {
|
||||
let credentials = grpc.credentials.createInsecure()
|
||||
if (ca || cert || key) {
|
||||
console.log("Using TLS")
|
||||
@@ -26,11 +29,41 @@ export function describe(url, ca, cert, key, handler) {
|
||||
cert ? fs.readFileSync(cert) : null
|
||||
);
|
||||
}
|
||||
const client = new emerald.Blockchain(
|
||||
console.log('Connecting to: ' + url + '...')
|
||||
return new emerald.Blockchain(
|
||||
url,
|
||||
credentials
|
||||
);
|
||||
}
|
||||
|
||||
console.log('Connecting to: ' + url + '...')
|
||||
export function describe(client, handler) {
|
||||
client.Describe({}, handler);
|
||||
}
|
||||
|
||||
export function nativeCall(client, chainCode, chain) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const call = client.NativeCall({
|
||||
chain: chainCode,
|
||||
items: [{
|
||||
id: id++,
|
||||
method: "eth_getBalance",
|
||||
payload: "WyIweDhEOTc2ODlDOTgxODg5MkI3MDBlMjdGMzE2Y2MzRTQxZTE3ZkJlYjkiLCAibGF0ZXN0Il0="
|
||||
}],
|
||||
quorum: 1,
|
||||
min_availability: 0
|
||||
})
|
||||
call.on('data', (item) => {
|
||||
resolve(toResult(chain, item, null))
|
||||
})
|
||||
call.on('end', () => resolve(toResult(chain, null, null)))
|
||||
call.on('error', (e) => reject(toResult(chain, null, e)))
|
||||
})
|
||||
}
|
||||
|
||||
function toResult(chain, obj, err) {
|
||||
return {
|
||||
chain: chain,
|
||||
payload: obj,
|
||||
error: err
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user