File tree Expand file tree Collapse file tree 5 files changed +25
-11
lines changed
contrib/core-contract-tests/tests/sip-031/commands Expand file tree Collapse file tree 5 files changed +25
-11
lines changed Original file line number Diff line number Diff line change 1
1
import fc from "fast-check" ;
2
2
import type { Model , Real } from "./types" ;
3
- import { calculateClaimable , logCommand , trackCommandRun } from "./utils" ;
3
+ import {
4
+ calculateClaimable ,
5
+ getWalletNameByAddress ,
6
+ logCommand ,
7
+ trackCommandRun ,
8
+ } from "./utils" ;
4
9
import { expect } from "vitest" ;
5
10
import { txOk } from "@clarigen/test" ;
6
11
@@ -26,7 +31,7 @@ export const Claim = (accounts: Real["accounts"]) =>
26
31
model . totalClaimed += expectedClaim ;
27
32
28
33
logCommand ( {
29
- sender : r . sender ,
34
+ sender : getWalletNameByAddress ( r . sender ) ,
30
35
status : "ok" ,
31
36
action : "claim" ,
32
37
value : `amount ${ expectedClaim } ` ,
Original file line number Diff line number Diff line change 1
1
import fc from "fast-check" ;
2
2
import type { Model , Real } from "./types" ;
3
- import { calculateClaimable , logCommand , trackCommandRun } from "./utils" ;
3
+ import {
4
+ calculateClaimable ,
5
+ getWalletNameByAddress ,
6
+ logCommand ,
7
+ trackCommandRun ,
8
+ } from "./utils" ;
4
9
import { expect } from "vitest" ;
5
10
import { txErr } from "@clarigen/test" ;
6
11
@@ -35,7 +40,7 @@ export const ClaimErr = (accounts: Real["accounts"]) =>
35
40
? "ERR_NOT_ALLOWED"
36
41
: "ERR_NOTHING_TO_CLAIM" ;
37
42
logCommand ( {
38
- sender : r . sender ,
43
+ sender : getWalletNameByAddress ( r . sender ) ,
39
44
status : "err" ,
40
45
action : "claim-err" ,
41
46
error : errString ,
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import fc from "fast-check";
2
2
import type { Model , Real } from "./types" ;
3
3
import { expect } from "vitest" ;
4
4
import { txOk } from "@clarigen/test" ;
5
- import { logCommand , trackCommandRun } from "./utils" ;
5
+ import { getWalletNameByAddress , logCommand , trackCommandRun } from "./utils" ;
6
6
7
7
export const UpdateRecipient = ( accounts : Real [ "accounts" ] ) =>
8
8
fc . record ( {
@@ -30,10 +30,10 @@ export const UpdateRecipient = (accounts: Real["accounts"]) =>
30
30
model . recipient = r . newRecipient ;
31
31
32
32
logCommand ( {
33
- sender : r . sender ,
33
+ sender : getWalletNameByAddress ( r . sender ) ,
34
34
status : "ok" ,
35
35
action : "update-recipient" ,
36
- value : `to ${ r . newRecipient } ` ,
36
+ value : `to ${ getWalletNameByAddress ( r . newRecipient ) } ` ,
37
37
} ) ;
38
38
} ,
39
39
toString : ( ) => `update-recipient to ${ r . newRecipient } ` ,
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import fc from "fast-check";
2
2
import type { Model , Real } from "./types" ;
3
3
import { expect } from "vitest" ;
4
4
import { txErr } from "@clarigen/test" ;
5
- import { logCommand , trackCommandRun } from "./utils" ;
5
+ import { getWalletNameByAddress , logCommand , trackCommandRun } from "./utils" ;
6
6
7
7
export const UpdateRecipientErr = ( accounts : Real [ "accounts" ] ) =>
8
8
fc . record ( {
@@ -26,7 +26,7 @@ export const UpdateRecipientErr = (accounts: Real["accounts"]) =>
26
26
expect ( receipt . value ) . toBe ( model . constants . ERR_NOT_ALLOWED ) ;
27
27
28
28
logCommand ( {
29
- sender : r . sender ,
29
+ sender : getWalletNameByAddress ( r . sender ) ,
30
30
status : "err" ,
31
31
action : "update-recipient-err" ,
32
32
error : "ERR_NOT_ALLOWED" ,
Original file line number Diff line number Diff line change 1
1
import type { Model } from "./types" ;
2
+ import { accounts } from "../../clarigen-types" ;
2
3
3
4
export function calculateClaimable ( model : Readonly < Model > ) : bigint {
4
5
const c = model . constants ;
@@ -35,7 +36,7 @@ export function logCommand({
35
36
value ?: string | number | bigint ;
36
37
error ?: string ;
37
38
} ) {
38
- const senderStr = ( sender ?? "system" ) . padEnd ( 41 , " " ) ;
39
+ const senderStr = ( sender ?? "system" ) . padEnd ( 11 , " " ) ;
39
40
const statusStr = status === "ok" ? "✓" : "✗" ;
40
41
const actionStr = action . padEnd ( 22 , " " ) ;
41
42
@@ -96,4 +97,7 @@ function logAsTree(statistics: [string, number][]) {
96
97
} ;
97
98
98
99
printTree ( tree ) ;
99
- }
100
+ }
101
+
102
+ export const getWalletNameByAddress = ( address : string ) : string | undefined =>
103
+ Object . entries ( accounts ) . find ( ( [ , v ] ) => v . address === address ) ?. [ 0 ] ;
You can’t perform that action at this time.
0 commit comments