solana/web3.js/test/budget-program.test.js

43 lines
982 B
JavaScript
Raw Normal View History

2018-09-18 12:46:59 -07:00
// @flow
import {Account} from '../src/account';
2018-09-20 10:10:46 -07:00
import {BudgetProgram} from '../src/budget-program';
2018-09-18 12:46:59 -07:00
test('pay', () => {
const from = new Account();
const contract = new Account();
const to = new Account();
let transaction;
2018-09-20 10:10:46 -07:00
transaction = BudgetProgram.pay(
2018-09-18 12:46:59 -07:00
from.publicKey,
contract.publicKey,
to.publicKey,
123,
);
console.log('Pay:', transaction);
2018-09-20 15:08:52 -07:00
// TODO: Validate transaction contents
2018-09-18 12:46:59 -07:00
2018-09-20 10:10:46 -07:00
transaction = BudgetProgram.pay(
2018-09-18 12:46:59 -07:00
from.publicKey,
contract.publicKey,
to.publicKey,
123,
2018-09-20 10:10:46 -07:00
BudgetProgram.signatureCondition(from.publicKey),
2018-09-18 12:46:59 -07:00
);
console.log('After:', transaction);
2018-09-20 15:08:52 -07:00
// TODO: Validate transaction contents
2018-09-18 12:46:59 -07:00
2018-09-20 10:10:46 -07:00
transaction = BudgetProgram.pay(
2018-09-18 12:46:59 -07:00
from.publicKey,
contract.publicKey,
to.publicKey,
123,
2018-09-20 10:10:46 -07:00
BudgetProgram.signatureCondition(from.publicKey),
BudgetProgram.timestampCondition(from.publicKey, new Date()),
2018-09-18 12:46:59 -07:00
);
console.log('Or:', transaction);
2018-09-20 15:08:52 -07:00
// TODO: Validate transaction contents
2018-09-18 12:46:59 -07:00
});