forked from toncenter/tonweb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added some helper test files to support tests in "typescripted" branch
Signed-off-by: Slava Fomin II <[email protected]>
- Loading branch information
1 parent
7a2732d
commit 379f393
Showing
4 changed files
with
125 additions
and
5 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
const { default: HttpProvider } = require('../../src/providers/index'); | ||
|
||
|
||
/** | ||
* A stub HTTP Provider that is used in tests. | ||
*/ | ||
class TestHttpProvider extends HttpProvider { | ||
|
||
constructor() { | ||
super('', {}); | ||
} | ||
|
||
|
||
async send(method, params) { | ||
return new Response('{}', { | ||
status: 200, | ||
statusText: 'OK', | ||
}); | ||
} | ||
|
||
} | ||
|
||
module.exports = { | ||
TestHttpProvider, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
|
||
const nacl = require('tweetnacl'); | ||
|
||
const TonWeb = require('../../src'); | ||
const utils = TonWeb.utils; | ||
const { TestHttpProvider } = require('./test-http-provider'); | ||
|
||
|
||
const FakeTimers = require('@sinonjs/fake-timers'); | ||
FakeTimers.install(); | ||
|
||
|
||
(async () => { | ||
|
||
const testProvider = new TestHttpProvider(); | ||
|
||
// Address: UQC63Lo54ZfLTGo12UECZc8Ba3g-dEVhvzy7Vroe43-AQzAe | ||
const keyPair = nacl.sign.keyPair.fromSeed( | ||
new Uint8Array(32) | ||
); | ||
|
||
const wallet = new TonWeb.Wallets.all.v4R2( | ||
testProvider, { | ||
publicKey: keyPair.publicKey, | ||
} | ||
); | ||
|
||
const method = wallet.methods.transfer({ | ||
secretKey: keyPair.secretKey, | ||
toAddress: 'UQC63Lo54ZfLTGo12UECZc8Ba3g-dEVhvzy7Vroe43-AQzAe', | ||
amount: 1050, | ||
seqno: 1, | ||
}); | ||
|
||
const queryCell = await method.getQuery(); | ||
const queryBoc = await queryCell.toBoc(); | ||
const queryBocB64 = utils.bytesToBase64(queryBoc); | ||
|
||
console.log(queryBocB64); | ||
|
||
})(); |