-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem: missing property-base testing (fix #857) #862
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import 'mocha'; | ||
import * as fc from 'fast-check'; | ||
import { DefaultWalletConfigs } from '../../config/StaticConfig'; | ||
import sdk from '@crypto-org-chain/chain-jslib'; | ||
import { Units } from '../../utils/ChainJsLib'; | ||
import { assert } from 'console'; | ||
|
||
test('should declare coin in ledger correctly', () => { | ||
fc.assert( | ||
// both inclusive | ||
fc.property(fc.bigInt(BigInt('1'), BigInt('10000000000000000000')), coinAmount => { | ||
const cro = sdk.CroSDK({ network: DefaultWalletConfigs.TestNetConfig.network }); | ||
const fee = new cro.Coin(coinAmount.toString(), Units.BASE); | ||
assert(fee.toString() === coinAmount.toString()); | ||
return true; | ||
}), | ||
{ verbose: true }, | ||
); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
import 'mocha'; | ||
import { expect } from 'chai'; | ||
import * as fc from 'fast-check'; | ||
import { DefaultWalletConfigs, WalletConfig } from '../../config/StaticConfig'; | ||
import { TransactionSigner } from './TransactionSigner'; | ||
import { TransactionUnsigned } from './TransactionSupported'; | ||
import { evmTransactionSigner } from './EvmTransactionSigner'; | ||
|
||
import * as RLP from '@ethersproject/rlp'; | ||
const testNet = DefaultWalletConfigs.TestNetConfig; | ||
// Overridden testnet chainId | ||
const testNetConfig: WalletConfig = { | ||
|
@@ -120,3 +121,36 @@ describe('Testing TransactionSigner', () => { | |
); | ||
}); | ||
}); | ||
|
||
test('should transfer correctly', async () => { | ||
const phrase = | ||
'team school reopen cave banner pass autumn march immune album hockey region baby critic insect armor pigeon owner number velvet romance flight blame tone'; | ||
|
||
fc.assert( | ||
fc.asyncProperty( | ||
fc.integer({ min: 1, max: 100000000000 }) /* gas limit range */, | ||
fc.bigInt(BigInt('1'), BigInt('100000000000000000000000000000000')) /* amount range */, | ||
async (gasLimit, amount) => { | ||
const transferTxSignedHex = await evmTransactionSigner.signTransfer( | ||
{ | ||
amount: amount.toString(), | ||
fromAddress: '0xc2aFcEC3DAfAF1a4f47030eE35Fd1A1231C08256', | ||
gasLimit: gasLimit, | ||
gasPrice: 5_000_000, | ||
nonce: 12, | ||
toAddress: '0x8875bF87684f46111dbc27725332CEA9C0f12D39', | ||
accountNumber: 0, | ||
accountSequence: 0, | ||
memo: '', | ||
}, | ||
phrase, | ||
); | ||
const decodedTransaction = RLP.decode(transferTxSignedHex); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
expect(transferTxSignedHex !== '').to.eq(true); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could also check There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. package.json There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
expect(BigInt(decodedTransaction[4]) === amount).to.eq(true); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
return true; | ||
}, | ||
), | ||
{ verbose: true }, | ||
); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the property here?
cro.Coin
not throwing an exception?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whether coin can be created to the maximum, that will not throw any exception