Skip to content
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

Fix console.log unsigned int print. #1210

Merged
merged 2 commits into from
Feb 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { bufferToHex, bufferToInt, fromSigned } from "ethereumjs-util";
import { BN, bufferToHex, bufferToInt, fromSigned } from "ethereumjs-util";
import util from "util";

import {
Expand Down Expand Up @@ -130,6 +130,10 @@ export class ConsoleLogger {
const position = i * 32;
switch (types[i]) {
case UintTy:
return new BN(
data.slice(position, position + REGISTER_SIZE)
).toString(10);

case IntTy:
return fromSigned(
data.slice(position, position + REGISTER_SIZE)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
pragma solidity ^0.5.0;

import "./../../../../../../../../console.sol";

contract C {

function log(
uint256 p0, uint256 p1, int256 p2, int256 p3
) public {
console.log(p0);
console.log(p1);
console.logInt(p2);
console.logInt(p3);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"description": "Should correctly interpret sign of integer types",
"transactions": [
{
"file": "c.sol",
"contract": "C",
"imports": ["/../../../../../../../../../console.sol"]
},
{
"to": 0,
"function": "log",
"params": [
"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
"0x8000000000000000000000000000000000000000000000000000000000000000",
"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
"0x8000000000000000000000000000000000000000000000000000000000000000"
],
"consoleLogs": [
["115792089237316195423570985008687907853269984665640564039457584007913129639935"],
["57896044618658097711785492504343953926634992332820282019728792003956564819968"],
["-1"],
["-57896044618658097711785492504343953926634992332820282019728792003956564819968"]
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
pragma solidity ^0.6.0;

import "./../../../../../../../../console.sol";

contract C {

function log(
uint256 p0, uint256 p1, int256 p2, int256 p3
) public {
console.log(p0);
console.log(p1);
console.logInt(p2);
console.logInt(p3);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"description": "Should correctly interpret sign of integer types",
"transactions": [
{
"file": "c.sol",
"contract": "C",
"imports": ["/../../../../../../../../../console.sol"]
},
{
"to": 0,
"function": "log",
"params": [
"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
"0x8000000000000000000000000000000000000000000000000000000000000000",
"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
"0x8000000000000000000000000000000000000000000000000000000000000000"
],
"consoleLogs": [
["115792089237316195423570985008687907853269984665640564039457584007913129639935"],
["57896044618658097711785492504343953926634992332820282019728792003956564819968"],
["-1"],
["-57896044618658097711785492504343953926634992332820282019728792003956564819968"]
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
pragma solidity ^0.7.0;

import "./../../../../../../../../console.sol";

contract C {

function log(
uint256 p0, uint256 p1, int256 p2, int256 p3
) public {
console.log(p0);
console.log(p1);
console.logInt(p2);
console.logInt(p3);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"description": "Should correctly interpret sign of integer types",
"transactions": [
{
"file": "c.sol",
"contract": "C",
"imports": ["/../../../../../../../../../console.sol"]
},
{
"to": 0,
"function": "log",
"params": [
"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
"0x8000000000000000000000000000000000000000000000000000000000000000",
"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
"0x8000000000000000000000000000000000000000000000000000000000000000"
],
"consoleLogs": [
["115792089237316195423570985008687907853269984665640564039457584007913129639935"],
["57896044618658097711785492504343953926634992332820282019728792003956564819968"],
["-1"],
["-57896044618658097711785492504343953926634992332820282019728792003956564819968"]
]
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -392,13 +392,7 @@ async function runTest(

const txIndexToContract: Map<number, DeployedContract> = new Map();

for (
let txIndex = 0;
txIndex < testDefinition.transactions.length;
txIndex++
) {
const tx = testDefinition.transactions[txIndex];

for (const [txIndex, tx] of testDefinition.transactions.entries()) {
let trace: MessageTrace;

if ("file" in tx) {
Expand Down