EExcel 丞燕快速查詢2

EExcel 丞燕快速查詢2
EExcel 丞燕快速查詢2 https://sandk.ffbizs.com/

mocha supertest geth mine


1、node & npm

apk add nodejs npm nano curl


2、mkdir t   put files to t or nano test.js

2.1、nano test.js



var supertest = require('supertest');

describe('GET http://go-ethe:8545/', function () {

    let request = supertest('http://go-ethe:8545')
    it('respond with json 1', function (done) {
        request.post('/')
            .send({"jsonrpc":"2.0","method":"miner_start","params":[1],"id":1})
            .expect('Content-Type', /json/)
            .expect(200, done);
    });

    let gethcmd = {"jsonrpc":"2.0","method":"eth_mining","params":[],"id":1}
    it('respond with json mining actively start ', function (done) {
        request.post('/')
            .send(gethcmd)
            .expect('Content-Type', /json/)
            .expect(200)
            .expect((res)=>{if (!(true == res.body.result) ) throw new Error("mining actively start failed!"); })
            .end(done);
    });

    it('respond with json 2', function (done) {
        request.post('/')
            .send({"jsonrpc":"2.0","method":"miner_stop","params":[],"id":1})
            .expect('Content-Type', /json/)
            .expect(200, done);
    });

    let gethcmd2 = {"jsonrpc":"2.0","method":"eth_mining","params":[],"id":1}
    it('respond with json mining actively stop ', function (done) {
        request.post('/')
            .send(gethcmd2)
            .expect('Content-Type', /json/)
            .expect(200)
            .expect((res)=>{if (!(false == res.body.result) ) throw new Error("mining actively stop failed!"); })
            .end(done);
    });

});



3、npm init -y && npm i -S supertest mocha


4、npm init get .node_modules directory, npm i -S get mocha & supertest

RUN> ./node_modules/mocha/bin/mocha test.js





====================
https://willi.am/blog/2014/07/28/test-your-api-with-supertest/


request.
    .get('/')
    .expect({message: "Hello, World!"}, done);

This way {ooxx: ooxx, ooxx: ooxx} must put all detail.


====================
curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"miner_start","params":[1],"id":1}' go-ethe:8545


curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"miner_stop","params":[],"id":1}' go-ethe:8545


Method
https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_mining