Skip to content

Commit

Permalink
Fix active auth tests to use a testing authority #458
Browse files Browse the repository at this point in the history
  • Loading branch information
mvandeberg committed Oct 31, 2019
1 parent e982739 commit c9dadd2
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/api/methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ export default [
{
"api": "database_api",
"method": "verify_authority",
"params": ["trx"]
"params": ["trx", "auth"]
},
{
"api": "database_api",
Expand Down
18 changes: 12 additions & 6 deletions test/hf20-accounts.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,14 @@ import should from 'should';
import steem from '../src';

const username = process.env.STEEM_USERNAME || 'guest123';
const password = process.env.STEEM_PASSWORD;
const activeWif = steem.auth.toWif(username, password, 'active');
const passwrod = process.env.STEEM_PASSWORD;
const activeWif = '5K4RDXLLjoyvKttRj8jG9utT7GZmM9qNkePT6uRfWxKf19g322R';
const activePub = steem.auth.wifToPublic( activeWif );
const testAuth = {
'weight_threshold': 1,
'account_auths': [],
'key_auths': [[activePub, 1]]
};

describe('steem.hf20-accounts:', () => {
it('has generated methods', () => {
Expand All @@ -20,9 +26,10 @@ describe('steem.hf20-accounts:', () => {

describe('claimAccount', () => {

/* Skip these tests. Steem-js test infrastructure not set up for testing active auths
Blocked by Steem issue #3546
it('signs and verifies auth', function(done) {
let url = steem.config.get('uri');
steem.api.setOptions({ url: url, useAppbaseApi: true });

let tx = {
'operations': [[
'claim_account', {
Expand All @@ -35,7 +42,7 @@ describe('steem.hf20-accounts:', () => {

steem.broadcast._prepareTransaction(tx).then(function(tx){
tx = steem.auth.signTransaction(tx, [activeWif]);
steem.api.verifyAuthorityAsync(tx).then(
steem.api.verifyAuthorityAsync(tx, testAuth).then(
(result) => {result.should.equal(true); done();},
(err) => {done(err);}
);
Expand Down Expand Up @@ -71,6 +78,5 @@ describe('steem.hf20-accounts:', () => {
}, (err) => {done(err)});
});
});
*/
});
});
16 changes: 10 additions & 6 deletions test/hf21-sps.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@ import should from 'should';
import steem from '../src';

const username = process.env.STEEM_USERNAME || 'guest123';
const password = process.env.STEEM_PASSWORD;
const activeWif = steem.auth.toWif(username, password, 'active');
const activeWif = '5K4RDXLLjoyvKttRj8jG9utT7GZmM9qNkePT6uRfWxKf19g322R';
const activePub = steem.auth.wifToPublic( activeWif );
const testAuth = {
'weight_threshold': 1,
'account_auths': [],
'key_auths': [[activePub, 1]]
};

describe('steem.hf21-accounts:', () => {
it('has generated methods', () => {
Expand All @@ -21,9 +26,9 @@ describe('steem.hf21-accounts:', () => {
});

describe('create proposal ops', () => {
/* Skip these tests. Steem-js test infrastructure not set up for testing active auths
Blocked by Steem issue #3546
it('signs and verifies create_proposal', function(done) {
let url = steem.config.get('uri');
steem.api.setOptions({ url: url, useAppbaseApi: true });
let permlink = 'test';

let tx = {
Expand All @@ -45,7 +50,7 @@ describe('steem.hf21-accounts:', () => {

steem.broadcast._prepareTransaction(tx).then(function(tx){
tx = steem.auth.signTransaction(tx, [activeWif]);
steem.api.verifyAuthorityAsync(tx).then(
steem.api.verifyAuthorityAsync(tx, testAuth).then(
(result) => {result.should.equal(true); done();},
(err) => {done(err);}
);
Expand Down Expand Up @@ -73,6 +78,5 @@ describe('steem.hf21-accounts:', () => {
);
});
})
*/
});
});
27 changes: 16 additions & 11 deletions test/smt.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@ import should from 'should';
import steem from '../src';

const username = process.env.STEEM_USERNAME || 'guest123';
const password = process.env.STEEM_PASSWORD;
const activeWif = steem.auth.toWif(username, password, 'active');
const activeWif = '5K4RDXLLjoyvKttRj8jG9utT7GZmM9qNkePT6uRfWxKf19g322R';
const activePub = steem.auth.wifToPublic( activeWif );
const testAuth = {
'weight_threshold': 1,
'account_auths': [],
'key_auths': [[activePub, 1]]
};

describe('steem.smt:', () => {

Expand All @@ -30,7 +35,7 @@ describe('steem.smt:', () => {

steem.broadcast._prepareTransaction(tx).then(function(tx){
tx = steem.auth.signTransaction(tx, [activeWif]);
steem.api.verifyAuthorityAsync(tx).then(
steem.api.verifyAuthorityAsync(tx, testAuth).then(
(result) => {result.should.equal(true); done();},
(err) => {done(err);}
);
Expand Down Expand Up @@ -98,7 +103,7 @@ describe('steem.smt:', () => {

steem.broadcast._prepareTransaction(tx).then(function(tx){
tx = steem.auth.signTransaction(tx, [activeWif]);
steem.api.verifyAuthorityAsync(tx).then(
steem.api.verifyAuthorityAsync(tx, testAuth).then(
(result) => {result.should.equal(true); done();},
(err) => {done(err);}
);
Expand Down Expand Up @@ -141,7 +146,7 @@ describe('steem.smt:', () => {

steem.broadcast._prepareTransaction(tx).then(function(tx){
tx = steem.auth.signTransaction(tx, [activeWif]);
steem.api.verifyAuthorityAsync(tx).then(
steem.api.verifyAuthorityAsync(tx, testAuth).then(
(result) => {result.should.equal(true); done();},
(err) => {done(err);}
);
Expand Down Expand Up @@ -169,7 +174,7 @@ describe('steem.smt:', () => {

steem.broadcast._prepareTransaction(tx).then(function(tx){
tx = steem.auth.signTransaction(tx, [activeWif]);
steem.api.verifyAuthorityAsync(tx).then(
steem.api.verifyAuthorityAsync(tx, testAuth).then(
(result) => {result.should.equal(true); done();},
(err) => {done(err);}
);
Expand Down Expand Up @@ -198,7 +203,7 @@ describe('steem.smt:', () => {

steem.broadcast._prepareTransaction(tx).then(function(tx){
tx = steem.auth.signTransaction(tx, [activeWif]);
steem.api.verifyAuthorityAsync(tx).then(
steem.api.verifyAuthorityAsync(tx, testAuth).then(
(result) => {result.should.equal(true); done();},
(err) => {done(err);}
);
Expand All @@ -224,7 +229,7 @@ describe('steem.smt:', () => {

steem.broadcast._prepareTransaction(tx).then(function(tx){
tx = steem.auth.signTransaction(tx, [activeWif]);
steem.api.verifyAuthorityAsync(tx).then(
steem.api.verifyAuthorityAsync(tx, testAuth).then(
(result) => {result.should.equal(true); done();},
(err) => {done(err);}
);
Expand Down Expand Up @@ -259,7 +264,7 @@ describe('steem.smt:', () => {

steem.broadcast._prepareTransaction(tx).then(function(tx){
tx = steem.auth.signTransaction(tx, [activeWif]);
steem.api.verifyAuthorityAsync(tx).then(
steem.api.verifyAuthorityAsync(tx, testAuth).then(
(result) => {result.should.equal(true); done();},
(err) => {done(err);}
);
Expand Down Expand Up @@ -296,7 +301,7 @@ describe('steem.smt:', () => {

steem.broadcast._prepareTransaction(tx).then(function(tx){
tx = steem.auth.signTransaction(tx, [activeWif]);
steem.api.verifyAuthorityAsync(tx).then(
steem.api.verifyAuthorityAsync(tx, testAuth).then(
(result) => {result.should.equal(true); done();},
(err) => {done(err);}
);
Expand Down Expand Up @@ -325,7 +330,7 @@ describe('steem.smt:', () => {

steem.broadcast._prepareTransaction(tx).then(function(tx){
tx = steem.auth.signTransaction(tx, [activeWif]);
steem.api.verifyAuthorityAsync(tx).then(
steem.api.verifyAuthorityAsync(tx, testAuth).then(
(result) => {result.should.equal(true); done();},
(err) => {done(err);}
);
Expand Down

0 comments on commit c9dadd2

Please sign in to comment.