@ -1212,18 +1212,20 @@ describe('Transaction Controller', function () {
const expectedPayload = {
event : 'Transaction Added' ,
category : 'Transactions' ,
sensitiveP roperties: {
p roperties: {
chain _id : '0x2a' ,
gas _price : '0x77359400' ,
gas _limit : '0x7b0d' ,
first _seen : 1624408066355 ,
transaction _envelope _type : 'legacy' ,
network : '42' ,
referrer : 'metamask' ,
source : 'user' ,
status : 'unapproved' ,
type : 'sentEther' ,
} ,
sensitiveProperties : {
gas _price : '2' ,
gas _limit : '0x7b0d' ,
first _seen : 1624408066355 ,
transaction _envelope _type : 'legacy' ,
status : 'unapproved' ,
} ,
} ;
txController . _trackTransactionMetricsEvent (
@ -1257,18 +1259,20 @@ describe('Transaction Controller', function () {
const expectedPayload = {
event : 'Transaction Added' ,
category : 'Transactions' ,
sensitiveP roperties: {
p roperties: {
chain _id : '0x2a' ,
gas _price : '0x77359400' ,
gas _limit : '0x7b0d' ,
first _seen : 1624408066355 ,
transaction _envelope _type : 'legacy' ,
network : '42' ,
referrer : 'other' ,
source : 'dapp' ,
status : 'unapproved' ,
type : 'sentEther' ,
} ,
sensitiveProperties : {
gas _price : '2' ,
gas _limit : '0x7b0d' ,
first _seen : 1624408066355 ,
transaction _envelope _type : 'legacy' ,
status : 'unapproved' ,
} ,
} ;
txController . _trackTransactionMetricsEvent (
@ -1302,19 +1306,21 @@ describe('Transaction Controller', function () {
const expectedPayload = {
event : 'Transaction Added' ,
category : 'Transactions' ,
properties : {
network : '42' ,
referrer : 'other' ,
source : 'dapp' ,
type : 'sentEther' ,
chain _id : '0x2a' ,
} ,
sensitiveProperties : {
baz : 3.0 ,
foo : 'bar' ,
chain _id : '0x2a' ,
gas _price : '0x77359400' ,
gas _price : '2' ,
gas _limit : '0x7b0d' ,
first _seen : 1624408066355 ,
transaction _envelope _type : 'legacy' ,
network : '42' ,
referrer : 'other' ,
source : 'dapp' ,
status : 'unapproved' ,
type : 'sentEther' ,
} ,
} ;
@ -1354,20 +1360,22 @@ describe('Transaction Controller', function () {
const expectedPayload = {
event : 'Transaction Added' ,
category : 'Transactions' ,
properties : {
chain _id : '0x2a' ,
network : '42' ,
referrer : 'other' ,
source : 'dapp' ,
type : 'sentEther' ,
} ,
sensitiveProperties : {
baz : 3.0 ,
foo : 'bar' ,
chain _id : '0x2a' ,
max _fee _per _gas : '0x77359400' ,
max _priority _fee _per _gas : '0x77359400' ,
max _fee _per _gas : '2' ,
max _priority _fee _per _gas : '2' ,
gas _limit : '0x7b0d' ,
first _seen : 1624408066355 ,
transaction _envelope _type : 'fee-market' ,
network : '42' ,
referrer : 'other' ,
source : 'dapp' ,
status : 'unapproved' ,
type : 'sentEther' ,
} ,
} ;
@ -1386,4 +1394,54 @@ describe('Transaction Controller', function () {
) ;
} ) ;
} ) ;
describe ( '#_getTransactionCompletionTime' , function ( ) {
let nowStub ;
beforeEach ( function ( ) {
nowStub = sinon . stub ( Date , 'now' ) . returns ( 1625782016341 ) ;
} ) ;
afterEach ( function ( ) {
nowStub . restore ( ) ;
} ) ;
it ( 'calculates completion time (one)' , function ( ) {
const submittedTime = 1625781997397 ;
const result = txController . _getTransactionCompletionTime ( submittedTime ) ;
assert . equal ( result , '19' ) ;
} ) ;
it ( 'calculates completion time (two)' , function ( ) {
const submittedTime = 1625781995397 ;
const result = txController . _getTransactionCompletionTime ( submittedTime ) ;
assert . equal ( result , '21' ) ;
} ) ;
} ) ;
describe ( '#_getGasValuesInGWEI' , function ( ) {
it ( 'converts gas values in hex GWEi to dec GWEI (EIP-1559)' , function ( ) {
const params = {
max _fee _per _gas : '0x77359400' ,
max _priority _fee _per _gas : '0x77359400' ,
} ;
const expectedParams = {
max _fee _per _gas : '2' ,
max _priority _fee _per _gas : '2' ,
} ;
const result = txController . _getGasValuesInGWEI ( params ) ;
assert . deepEqual ( result , expectedParams ) ;
} ) ;
it ( 'converts gas values in hex GWEi to dec GWEI (non EIP-1559)' , function ( ) {
const params = {
gas _price : '0x37e11d600' ,
} ;
const expectedParams = {
gas _price : '15' ,
} ;
const result = txController . _getGasValuesInGWEI ( params ) ;
assert . deepEqual ( result , expectedParams ) ;
} ) ;
} ) ;
} ) ;