@@ -27,7 +27,7 @@ describe("KlerosCoreRuler", async () => {
27
27
[ core , resolver ] = await deployContracts ( deployer ) ;
28
28
} ) ;
29
29
30
- it ( "Kleros Core initialization " , async ( ) => {
30
+ it ( "Should have initialized the Arbitrator " , async ( ) => {
31
31
// Reminder: the Forking court will be added which will break these expectations.
32
32
let events = await core . queryFilter ( core . filters . CourtCreated ( ) ) ;
33
33
expect ( events . length ) . to . equal ( 1 ) ;
@@ -45,27 +45,71 @@ describe("KlerosCoreRuler", async () => {
45
45
} ) ;
46
46
47
47
it ( "Should create a dispute and automatically execute a random ruling" , async ( ) => {
48
- await expect (
49
- resolver . createDisputeForTemplate ( extraData , "" , "" , 3 , { value : ethers . utils . parseEther ( "0.3" ) } )
50
- ) . to . be . revertedWithCustomError ( core , "RulingModeNotSet" ) ;
51
-
52
48
await expect ( core . changeRulingModeToAutomaticRandom ( resolver . address ) )
53
49
. to . emit ( core , "RulerSettingsChanged" )
54
50
. withArgs ( resolver . address , [ RulingMode . automaticRandom , 0 , false , false ] ) ;
55
51
52
+ const disputeID = 0 ;
53
+
54
+ await expect ( resolver . createDisputeForTemplate ( extraData , "" , "" , 3 , { value : ethers . utils . parseEther ( "0.3" ) } ) )
55
+ . to . emit ( core , "DisputeCreation" )
56
+ . withArgs ( disputeID , resolver . address )
57
+ . and . to . emit ( core , "AutoRuled" )
58
+ . withArgs ( resolver . address , RulingMode . automaticRandom , disputeID , anyValue , anyValue , anyValue )
59
+ . and . to . emit ( core , "Ruling" )
60
+ . withArgs ( resolver . address , disputeID , anyValue )
61
+ . and . to . emit ( core , "TokenAndETHShift" )
62
+ . withArgs ( deployer . address , disputeID , 0 , 1 , 0 , anyValue , ethers . constants . AddressZero )
63
+ . and . to . emit ( resolver , "DisputeRequest" )
64
+ . withArgs ( core . address , disputeID , disputeID , disputeID , "" )
65
+ . and . to . emit ( resolver , "Ruling" )
66
+ . withArgs ( core . address , disputeID , anyValue ) ;
67
+ } ) ;
68
+
69
+ it ( "Should create a dispute and automatically execute a preset ruling" , async ( ) => {
70
+ await expect ( core . changeRulingModeToAutomaticPreset ( resolver . address , 2 , true , false ) )
71
+ . to . emit ( core , "RulerSettingsChanged" )
72
+ . withArgs ( resolver . address , [ RulingMode . automaticPreset , 2 , true , false ] ) ;
73
+
74
+ const disputeID = 1 ;
75
+
56
76
await expect ( resolver . createDisputeForTemplate ( extraData , "" , "" , 3 , { value : ethers . utils . parseEther ( "0.3" ) } ) )
57
77
. to . emit ( core , "DisputeCreation" )
58
- . withArgs ( 0 , resolver . address )
78
+ . withArgs ( disputeID , resolver . address )
59
79
. and . to . emit ( core , "AutoRuled" )
60
- . withArgs ( resolver . address , RulingMode . automaticRandom , 0 , anyValue , anyValue , anyValue )
80
+ . withArgs ( resolver . address , RulingMode . automaticPreset , disputeID , 2 , true , false )
61
81
. and . to . emit ( core , "Ruling" )
62
- . withArgs ( resolver . address , 0 , anyValue )
82
+ . withArgs ( resolver . address , disputeID , 2 )
63
83
. and . to . emit ( core , "TokenAndETHShift" )
64
- . withArgs ( deployer . address , 0 , 0 , 1 , 0 , anyValue , ethers . constants . AddressZero )
84
+ . withArgs ( deployer . address , disputeID , 0 , 1 , 0 , anyValue , ethers . constants . AddressZero )
65
85
. and . to . emit ( resolver , "DisputeRequest" )
66
- . withArgs ( core . address , 0 , 1 , "" , "" )
86
+ . withArgs ( core . address , disputeID , disputeID , disputeID , "" )
67
87
. and . to . emit ( resolver , "Ruling" )
68
- . withArgs ( core . address , 0 , anyValue ) ;
88
+ . withArgs ( core . address , disputeID , 2 ) ;
89
+ } ) ;
90
+
91
+ it ( "Should create a dispute and manually execute a ruling" , async ( ) => {
92
+ await expect ( core . changeRulingModeToManual ( resolver . address ) )
93
+ . to . emit ( core , "RulerSettingsChanged" )
94
+ . withArgs ( resolver . address , [ RulingMode . manual , 0 , false , false ] ) ;
95
+
96
+ const disputeID = 2 ;
97
+
98
+ await expect ( resolver . createDisputeForTemplate ( extraData , "" , "" , 3 , { value : ethers . utils . parseEther ( "0.3" ) } ) )
99
+ . to . emit ( core , "DisputeCreation" )
100
+ . withArgs ( disputeID , resolver . address )
101
+ . and . to . emit ( resolver , "DisputeRequest" )
102
+ . withArgs ( core . address , disputeID , disputeID , disputeID , "" ) ;
103
+
104
+ await expect ( core . executeRuling ( disputeID , 3 , true , true ) )
105
+ . and . to . emit ( core , "Ruling" )
106
+ . withArgs ( resolver . address , disputeID , 3 )
107
+ . and . to . emit ( resolver , "Ruling" )
108
+ . withArgs ( core . address , disputeID , 3 ) ;
109
+
110
+ await expect ( core . execute ( disputeID , 0 ) )
111
+ . and . to . emit ( core , "TokenAndETHShift" )
112
+ . withArgs ( deployer . address , disputeID , 0 , 1 , 0 , anyValue , ethers . constants . AddressZero ) ;
69
113
} ) ;
70
114
} ) ;
71
115
0 commit comments