import test from "ava"; import dotenv from "dotenv"; import { Account } from "../../account/account"; import RpcMethod from "../../rpc-method"; import { ClaimFromRewardingFundMethod, ExecutionMethod, TransferMethod } from "../method"; dotenv.config(); export const TEST_ACCOUNT = { address: "io187wzp08vnhjjpkydnr97qlh8kh0dpkkytfam8j", privateKey: "0806c458b262edd333a191e92f561aff338211ee3e18ab315a074a2d82aa343f", publicKey: "044e18306ae9ef4ec9d07bf6e705442d4d1a75e6cdf750330ca2d880f2cc54607c9c33deb9eae9c06e06e04fe9ce3d43962cc67d5aa34fbeb71270d4bad3d648d9" }; const TEST_HOSTNAME = process.env.IOTEX_CORE || "http://localhost:14014"; test.skip("TransferMethod_execute", async t => { const client = new RpcMethod(TEST_HOSTNAME, 2, { timeout: 10000 }); const sender = Account.fromPrivateKey(TEST_ACCOUNT.privateKey); const method = new TransferMethod(client, sender, { amount: "8500000000000000", recipient: "io13zt8sznez2pf0q0hqdz2hyl938wak2fsjgdeml", payload: "68656c6c6f20776f726c6421", gasLimit: "100000", gasPrice: "10000000000000" }); const reps = await method.execute(); t.truthy(reps); }); test.skip("TransferMethod_execute_nogas", async t => { const client = new RpcMethod(TEST_HOSTNAME, 2, { timeout: 10000 }); const sender = Account.fromPrivateKey(TEST_ACCOUNT.privateKey); const method = new TransferMethod(client, sender, { amount: "1000000000000000000", recipient: "io13zt8sznez2pf0q0hqdz2hyl938wak2fsjgdeml", payload: "68656c6c6f20776f726c6421" }); const reps = await method.execute(); t.truthy(reps); }); test.skip("Execution_execute", async t => { const client = new RpcMethod(TEST_HOSTNAME, 2, { timeout: 10000 }); const sender = Account.fromPrivateKey(TEST_ACCOUNT.privateKey); const method = new ExecutionMethod(client, sender, { contract: "", amount: "0", data: Buffer.from( "608060405234801561001057600080fd5b50610370806100206000396000f3006080604052600436106100565763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416631e67bed8811461005b5780638965356f146100d1578063d0e30db01461012a575b600080fd5b6040805160206004803580820135601f81018490048402850184019095528484526100bf9436949293602493928401919081908401838280828437509497505050923573ffffffffffffffffffffffffffffffffffffffff16935061013492505050565b60408051918252519081900360200190f35b3480156100dd57600080fd5b506040805160206004803580820135601f81018490048402850184019095528484526100bf94369492936024939284019190819084018382808284375094975061018e9650505050505050565b6101326102a4565b005b6000806101408461018e565b60405190915073ffffffffffffffffffffffffffffffffffffffff84169082156108fc029083906000818181858888f19350505050158015610186573d6000803e3d6000fd5b509392505050565b6000600561029060024485426040516020018084815260200183805190602001908083835b602083106101d25780518252601f1990920191602091820191016101b3565b51815160209384036101000a60001901801990921691161790529201938452506040805180850381529382019081905283519395509350839290850191508083835b602083106102335780518252601f199092019160209182019101610214565b51815160209384036101000a600019018019909216911617905260405191909301945091925050808303816000865af1158015610274573d6000803e3d6000fd5b5050506040513d602081101561028957600080fd5b50516102dc565b81151561029957fe5b066001019050919050565b60408051348152905133917fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c919081900360200190a2565b600080805b602081101561033d5780600101602060ff160360080260020a848260208110151561030857fe5b7f010000000000000000000000000000000000000000000000000000000000000091901a8102040291909101906001016102e1565b50929150505600a165627a7a72305820d432ab12368e59501d1e616eeecda22f3f3b461a5c5a6b919a1d2331a2e105bc0029", "hex" ) }); const reps = await method.execute(); t.truthy(reps); }); test.skip("ClaimFronRewardingFundMethod_execute", async t => { const client = new RpcMethod(TEST_HOSTNAME, 2, { timeout: 10000 }); const sender = Account.fromPrivateKey(TEST_ACCOUNT.privateKey); const method = new ClaimFromRewardingFundMethod(client, sender, { amount: "0", gasLimit: "100000", gasPrice: "10000000000000", data: Buffer.from( "608060405234801561001057600080fd5b50610370806100206000396000f3006080604052600436106100565763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416631e67bed8811461005b5780638965356f146100d1578063d0e30db01461012a575b600080fd5b6040805160206004803580820135601f81018490048402850184019095528484526100bf9436949293602493928401919081908401838280828437509497505050923573ffffffffffffffffffffffffffffffffffffffff16935061013492505050565b60408051918252519081900360200190f35b3480156100dd57600080fd5b506040805160206004803580820135601f81018490048402850184019095528484526100bf94369492936024939284019190819084018382808284375094975061018e9650505050505050565b6101326102a4565b005b6000806101408461018e565b60405190915073ffffffffffffffffffffffffffffffffffffffff84169082156108fc029083906000818181858888f19350505050158015610186573d6000803e3d6000fd5b509392505050565b6000600561029060024485426040516020018084815260200183805190602001908083835b602083106101d25780518252601f1990920191602091820191016101b3565b51815160209384036101000a60001901801990921691161790529201938452506040805180850381529382019081905283519395509350839290850191508083835b602083106102335780518252601f199092019160209182019101610214565b51815160209384036101000a600019018019909216911617905260405191909301945091925050808303816000865af1158015610274573d6000803e3d6000fd5b5050506040513d602081101561028957600080fd5b50516102dc565b81151561029957fe5b066001019050919050565b60408051348152905133917fe1fffcc4923d04b559f4d29a8bfc6cda04eb5b0d3c460751c2402c5c5cc9109c919081900360200190a2565b600080805b602081101561033d5780600101602060ff160360080260020a848260208110151561030857fe5b7f010000000000000000000000000000000000000000000000000000000000000091901a8102040291909101906001016102e1565b50929150505600a165627a7a72305820d432ab12368e59501d1e616eeecda22f3f3b461a5c5a6b919a1d2331a2e105bc0029", "hex" ) }); const reps = await method.execute(); t.truthy(reps); });