More setvphash call tests.
This commit is contained in:
parent
e7a4657097
commit
b13e33d67f
|
@ -505,16 +505,24 @@ class PricecasterLib {
|
|||
/**
|
||||
* Starts a begin...commit section for commiting grouped transactions.
|
||||
*/
|
||||
this.beginVerifyTxGroup = async function () {
|
||||
this.beginTxGroup = function () {
|
||||
this.groupTx = []
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} sender The sender account (typically the VAA verification stateless program)
|
||||
* Adds a transaction to the group.
|
||||
* @param {} tx Transaction to add.
|
||||
*/
|
||||
this.addTxToGroup = function (tx) {
|
||||
this.groupTx.push(tx)
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {*} sender The sender account.
|
||||
* @param {function} signCallback The sign callback routine.
|
||||
* @returns Transaction id.
|
||||
*/
|
||||
this.commitVerifyTxGroup = async function (sender, signCallback) {
|
||||
this.commitTxGroup = async function (sender, signCallback) {
|
||||
algosdk.assignGroupID(this.groupTx)
|
||||
|
||||
// Sign the transactions
|
||||
|
|
|
@ -117,13 +117,39 @@ describe('VAA Processor Smart-contract Tests', function () {
|
|||
expect(vphstate).to.equal(compiledProgram.hash)
|
||||
})
|
||||
it('Must disallow setting stateless logic hash from non-owner', async function () {
|
||||
|
||||
const teal = 'test/temp/vaa-verify.teal'
|
||||
spawnSync('python', ['teal/wormhole/pyteal/vaa-verify.py', appId, teal])
|
||||
const program = fs.readFileSync(teal, 'utf8')
|
||||
const compiledProgram = await pclib.compileProgram(program)
|
||||
await expect(pclib.setVAAVerifyProgramHash(OTHER_ADDR, compiledProgram.hash, signCallback)).to.be.rejectedWith('Bad Request')
|
||||
})
|
||||
it('Must reject setting stateless logic hash from group transaction', async function () {
|
||||
const teal = 'test/temp/vaa-verify.teal'
|
||||
spawnSync('python', ['teal/wormhole/pyteal/vaa-verify.py', appId, teal])
|
||||
const program = fs.readFileSync(teal, 'utf8')
|
||||
const compiledProgram = await pclib.compileProgram(program)
|
||||
const hash = algosdk.decodeAddress(compiledProgram.hash).publicKey
|
||||
const appArgs = [new Uint8Array(Buffer.from('setvphash')), hash.subarray(0, 10)]
|
||||
|
||||
const params = await algodClient.getTransactionParams().do()
|
||||
params.fee = 1000
|
||||
params.flatFee = true
|
||||
|
||||
pclib.beginTxGroup()
|
||||
const appTx = algosdk.makeApplicationNoOpTxn(OWNER_ADDR, params, this.appId, appArgs)
|
||||
const dummyTx = algosdk.makeApplicationNoOpTxn(OWNER_ADDR, params, this.appId, appArgs)
|
||||
pclib.addTxToGroup(appTx)
|
||||
pclib.addTxToGroup(dummyTx)
|
||||
await expect(pclib.commitTxGroup(OWNER_ADDR, signCallback)).to.be.rejectedWith('Bad Request')
|
||||
})
|
||||
it('Must reject setting stateless logic hash with invalid address length', async function () {
|
||||
|
||||
const teal = 'test/temp/vaa-verify.teal'
|
||||
spawnSync('python', ['teal/wormhole/pyteal/vaa-verify.py', appId, teal])
|
||||
const program = fs.readFileSync(teal, 'utf8')
|
||||
const compiledProgram = await pclib.compileProgram(program)
|
||||
const hash = algosdk.decodeAddress(compiledProgram.hash).publicKey
|
||||
const appArgs = [new Uint8Array(Buffer.from('setvphash')), hash.subarray(0, 10)]
|
||||
await expect(pclib.callApp(OWNER_ADDR, appArgs, [], signCallback)).to.be.rejectedWith('Bad Request')
|
||||
})
|
||||
it('Must verify and handle Pyth VAA', async function () {
|
||||
|
||||
|
|
Loading…
Reference in New Issue