Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
b342da50
Commit
b342da50
authored
Jan 22, 2020
by
aniket-engg
Committed by
Aniket
Jan 22, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests for value & VM transaction instance fix
parent
e6eaf6d9
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
19 deletions
+25
-19
txRunner.js
remix-lib/src/execution/txRunner.js
+8
-7
testRunner.ts
remix-tests/tests/testRunner.ts
+6
-6
sender_and_value_test.sol
remix-tests/tests/various_sender/sender_and_value_test.sol
+11
-6
No files found.
remix-lib/src/execution/txRunner.js
View file @
b342da50
...
@@ -95,7 +95,7 @@ class TxRunner {
...
@@ -95,7 +95,7 @@ class TxRunner {
runInVm
(
from
,
to
,
data
,
value
,
gasLimit
,
useCall
,
timestamp
,
callback
)
{
runInVm
(
from
,
to
,
data
,
value
,
gasLimit
,
useCall
,
timestamp
,
callback
)
{
const
self
=
this
const
self
=
this
var
account
=
self
.
vmaccounts
[
from
]
const
account
=
self
.
vmaccounts
[
from
]
if
(
!
account
)
{
if
(
!
account
)
{
return
callback
(
'Invalid account selected'
)
return
callback
(
'Invalid account selected'
)
}
}
...
@@ -104,19 +104,20 @@ class TxRunner {
...
@@ -104,19 +104,20 @@ class TxRunner {
if
(
err
)
{
if
(
err
)
{
callback
(
'Account not found'
)
callback
(
'Account not found'
)
}
else
{
}
else
{
var
tx
=
new
EthJSTX
({
// See https://github.com/ethereumjs/ethereumjs-tx/blob/master/docs/classes/transaction.md#constructor
timestamp
:
timestamp
,
// for initialization fields and their types
nonce
:
new
BN
(
res
.
nonce
),
const
tx
=
new
EthJSTX
({
gasPrice
:
new
BN
(
1
),
nonce
:
'0x'
+
res
.
nonce
.
toString
(
'hex'
),
gasPrice
:
'0x1'
,
gasLimit
:
gasLimit
,
gasLimit
:
gasLimit
,
to
:
to
,
to
:
to
,
value
:
new
BN
(
value
,
10
)
,
value
:
value
,
data
:
Buffer
.
from
(
data
.
slice
(
2
),
'hex'
)
data
:
Buffer
.
from
(
data
.
slice
(
2
),
'hex'
)
})
})
tx
.
sign
(
account
.
privateKey
)
tx
.
sign
(
account
.
privateKey
)
const
coinbases
=
[
'0x0e9281e9c6a0808672eaba6bd1220e144c9bb07a'
,
'0x8945a1288dc78a6d8952a92c77aee6730b414778'
,
'0x94d76e24f818426ae84aa404140e8d5f60e10e7e'
]
const
coinbases
=
[
'0x0e9281e9c6a0808672eaba6bd1220e144c9bb07a'
,
'0x8945a1288dc78a6d8952a92c77aee6730b414778'
,
'0x94d76e24f818426ae84aa404140e8d5f60e10e7e'
]
const
difficulties
=
[
new
BN
(
'69762765929000'
,
10
),
new
BN
(
'70762765929000'
,
10
),
new
BN
(
'71762765929000'
,
10
)]
const
difficulties
=
[
new
BN
(
'69762765929000'
,
10
),
new
BN
(
'70762765929000'
,
10
),
new
BN
(
'71762765929000'
,
10
)]
var
block
=
new
EthJSBlock
({
const
block
=
new
EthJSBlock
({
header
:
{
header
:
{
timestamp
:
timestamp
||
(
new
Date
().
getTime
()
/
1000
|
0
),
timestamp
:
timestamp
||
(
new
Date
().
getTime
()
/
1000
|
0
),
number
:
self
.
blockNumber
,
number
:
self
.
blockNumber
,
...
...
remix-tests/tests/testRunner.ts
View file @
b342da50
...
@@ -234,22 +234,22 @@ describe('testRunner', () => {
...
@@ -234,22 +234,22 @@ describe('testRunner', () => {
})
})
})
})
// Test Transaction with
different sender
// Test Transaction with
custom sender & value
describe
(
'various sender'
,
function
()
{
describe
(
'various sender'
,
function
()
{
const
filename
:
string
=
'tests/various_sender/sender_test.sol'
const
filename
:
string
=
'tests/various_sender/sender_
and_value_
test.sol'
before
(
function
(
done
)
{
before
(
function
(
done
)
{
compileAndDeploy
(
filename
,
function
(
_err
:
Error
|
null
|
undefined
,
compilationData
:
object
,
contracts
:
any
,
asts
:
any
,
accounts
:
string
[])
{
compileAndDeploy
(
filename
,
function
(
_err
:
Error
|
null
|
undefined
,
compilationData
:
object
,
contracts
:
any
,
asts
:
any
,
accounts
:
string
[])
{
runTest
(
'Sender
Test'
,
contracts
.
SenderTest
,
compilationData
[
filename
][
'Sender
Test'
],
asts
[
filename
],
{
accounts
},
testCallback
,
resultsCallback
(
done
))
runTest
(
'Sender
AndValueTest'
,
contracts
.
SenderAndValueTest
,
compilationData
[
filename
][
'SenderAndValue
Test'
],
asts
[
filename
],
{
accounts
},
testCallback
,
resultsCallback
(
done
))
})
})
})
})
after
(()
=>
{
tests
=
[]
})
after
(()
=>
{
tests
=
[]
})
it
(
'should have
4
passing tests'
,
function
()
{
it
(
'should have
5
passing tests'
,
function
()
{
assert
.
equal
(
results
.
passingNum
,
4
)
assert
.
equal
(
results
.
passingNum
,
5
)
})
})
it
(
'should have
1
failing tests'
,
function
()
{
it
(
'should have
0
failing tests'
,
function
()
{
assert
.
equal
(
results
.
failureNum
,
0
)
assert
.
equal
(
results
.
failureNum
,
0
)
})
})
})
})
...
...
remix-tests/tests/various_sender/sender_test.sol
→
remix-tests/tests/various_sender/sender_
and_value_
test.sol
View file @
b342da50
import "remix_tests.sol"; // this import is automatically injected by Remix.
import "remix_tests.sol"; // this import is automatically injected by Remix.
import "remix_accounts.sol";
import "remix_accounts.sol";
contract SenderTest {
contract Sender
AndValue
Test {
function beforeAll () public {}
function beforeAll () public {}
/// #sender: account-1
/// #sender: account-1
...
@@ -11,16 +11,21 @@ contract SenderTest {
...
@@ -11,16 +11,21 @@ contract SenderTest {
/// #sender: account-0
/// #sender: account-0
/// #value: 10
/// #value: 10
function checkSenderIs0 () public payable{
function checkSenderIs0AndValueis10 () public payable{
Assert.equal(msg.sender, TestsAccounts.getAccount(0), "wrong sender in checkSenderIs0");
Assert.equal(msg.sender, TestsAccounts.getAccount(0), "wrong sender in checkSenderIs0AndValueis10");
Assert.equal(msg.value, 10, "wrong value in checkSenderIs0AndValueis10");
}
}
/// #value: 100
/// #value: 100
function check
SenderIsNt
0 () public payable{
function check
ValueIs10
0 () public payable{
Assert.equal(msg.
sender, TestsAccounts.getAccount(0), "wrong sender in checkSenderIsNot
0");
Assert.equal(msg.
value, 100, "wrong value in checkValueIs10
0");
}
}
function checkSenderIsnt2 () public {
function checkSenderIsnt2 () public {
Assert.notEqual(msg.sender, TestsAccounts.getAccount(1), "wrong sender in checkSenderIsnt2");
Assert.notEqual(msg.sender, TestsAccounts.getAccount(2), "wrong sender in checkSenderIsnt2");
}
function checkValueIsnt10 () public payable{
Assert.notEqual(msg.value, 10, "wrong value in checkValueIsnt10");
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment