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();
|
2018-09-24 19:17:59 -07:00
|
|
|
const program = new Account();
|
2018-09-18 12:46:59 -07:00
|
|
|
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,
|
2018-09-24 19:17:59 -07:00
|
|
|
program.publicKey,
|
2018-09-18 12:46:59 -07:00
|
|
|
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,
|
2018-09-24 19:17:59 -07:00
|
|
|
program.publicKey,
|
2018-09-18 12:46:59 -07:00
|
|
|
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,
|
2018-09-24 19:17:59 -07:00
|
|
|
program.publicKey,
|
2018-09-18 12:46:59 -07:00
|
|
|
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
|
|
|
});
|
|
|
|
|