@@ -1984,89 +1984,125 @@ describe("TokenStaking", () => {
1984
1984
await tToken
1985
1985
. connect ( stakingProvider )
1986
1986
. approve ( tokenStaking . address , topUpAmount )
1987
- tx = await tokenStaking
1988
- . connect ( stakingProvider )
1989
- . topUp ( stakingProvider . address , topUpAmount )
1990
1987
} )
1991
1988
1992
- it ( "should update T staked amount" , async ( ) => {
1993
- await assertStake ( stakingProvider . address , expectedAmount )
1994
- } )
1989
+ context ( "when one of applications is paused" , ( ) => {
1990
+ it ( "should revert" , async ( ) => {
1991
+ await tokenStaking
1992
+ . connect ( deployer )
1993
+ . setPanicButton ( application1Mock . address , panicButton . address )
1994
+ await tokenStaking
1995
+ . connect ( panicButton )
1996
+ . pauseApplication ( application1Mock . address )
1995
1997
1996
- it ( "should not increase available amount to authorize" , async ( ) => {
1997
- expect (
1998
- await tokenStaking . getAvailableToAuthorize (
1999
- stakingProvider . address ,
2000
- application1Mock . address
2001
- )
2002
- ) . to . equal ( 0 )
2003
- expect (
2004
- await tokenStaking . getAvailableToAuthorize (
2005
- stakingProvider . address ,
2006
- application2Mock . address
2007
- )
2008
- ) . to . equal ( amount . sub ( authorized2 ) )
1998
+ await expect (
1999
+ tokenStaking
2000
+ . connect ( stakingProvider )
2001
+ . topUp ( stakingProvider . address , topUpAmount )
2002
+ ) . to . be . revertedWith ( "Application is not approved" )
2003
+ } )
2009
2004
} )
2010
2005
2011
- it ( "should increase authorized amount" , async ( ) => {
2012
- expect (
2013
- await tokenStaking . getMaxAuthorization ( stakingProvider . address )
2014
- ) . to . equal ( expectedAmount )
2015
- } )
2006
+ context ( "when one of applications is disabled" , ( ) => {
2007
+ it ( "should revert" , async ( ) => {
2008
+ await tokenStaking
2009
+ . connect ( deployer )
2010
+ . disableApplication ( application2Mock . address )
2016
2011
2017
- it ( "should emit ToppedUp event" , async ( ) => {
2018
- await expect ( tx )
2019
- . to . emit ( tokenStaking , "ToppedUp" )
2020
- . withArgs ( stakingProvider . address , topUpAmount )
2012
+ await expect (
2013
+ tokenStaking
2014
+ . connect ( stakingProvider )
2015
+ . topUp ( stakingProvider . address , topUpAmount )
2016
+ ) . to . be . revertedWith ( "Application is not approved" )
2017
+ } )
2021
2018
} )
2022
2019
2023
- it ( "should increase authorized amounts" , async ( ) => {
2024
- expect (
2025
- await tokenStaking . authorizedStake (
2026
- stakingProvider . address ,
2027
- application1Mock . address
2028
- )
2029
- ) . to . equal ( expectedAmount )
2030
- expect (
2031
- await tokenStaking . authorizedStake (
2032
- stakingProvider . address ,
2033
- application2Mock . address
2034
- )
2035
- ) . to . equal ( authorized2 . add ( topUpAmount ) )
2036
- } )
2020
+ context ( "when all applications are approved" , ( ) => {
2021
+ beforeEach ( async ( ) => {
2022
+ tx = await tokenStaking
2023
+ . connect ( stakingProvider )
2024
+ . topUp ( stakingProvider . address , topUpAmount )
2025
+ } )
2037
2026
2038
- it ( "should inform application" , async ( ) => {
2039
- await assertApplicationStakingProviders (
2040
- application1Mock ,
2041
- stakingProvider . address ,
2042
- expectedAmount ,
2043
- Zero
2044
- )
2045
- await assertApplicationStakingProviders (
2046
- application2Mock ,
2047
- stakingProvider . address ,
2048
- authorized2 . add ( topUpAmount ) ,
2049
- Zero
2050
- )
2051
- } )
2027
+ it ( "should update T staked amount" , async ( ) => {
2028
+ await assertStake ( stakingProvider . address , expectedAmount )
2029
+ } )
2052
2030
2053
- it ( "should emit AuthorizationIncreased" , async ( ) => {
2054
- await expect ( tx )
2055
- . to . emit ( tokenStaking , "AuthorizationIncreased" )
2056
- . withArgs (
2031
+ it ( "should not increase available amount to authorize" , async ( ) => {
2032
+ expect (
2033
+ await tokenStaking . getAvailableToAuthorize (
2034
+ stakingProvider . address ,
2035
+ application1Mock . address
2036
+ )
2037
+ ) . to . equal ( 0 )
2038
+ expect (
2039
+ await tokenStaking . getAvailableToAuthorize (
2040
+ stakingProvider . address ,
2041
+ application2Mock . address
2042
+ )
2043
+ ) . to . equal ( amount . sub ( authorized2 ) )
2044
+ } )
2045
+
2046
+ it ( "should increase authorized amount" , async ( ) => {
2047
+ expect (
2048
+ await tokenStaking . getMaxAuthorization ( stakingProvider . address )
2049
+ ) . to . equal ( expectedAmount )
2050
+ } )
2051
+
2052
+ it ( "should emit ToppedUp event" , async ( ) => {
2053
+ await expect ( tx )
2054
+ . to . emit ( tokenStaking , "ToppedUp" )
2055
+ . withArgs ( stakingProvider . address , topUpAmount )
2056
+ } )
2057
+
2058
+ it ( "should increase authorized amounts" , async ( ) => {
2059
+ expect (
2060
+ await tokenStaking . authorizedStake (
2061
+ stakingProvider . address ,
2062
+ application1Mock . address
2063
+ )
2064
+ ) . to . equal ( expectedAmount )
2065
+ expect (
2066
+ await tokenStaking . authorizedStake (
2067
+ stakingProvider . address ,
2068
+ application2Mock . address
2069
+ )
2070
+ ) . to . equal ( authorized2 . add ( topUpAmount ) )
2071
+ } )
2072
+
2073
+ it ( "should inform application" , async ( ) => {
2074
+ await assertApplicationStakingProviders (
2075
+ application1Mock ,
2057
2076
stakingProvider . address ,
2058
- application1Mock . address ,
2059
- authorized1 ,
2060
- expectedAmount
2077
+ expectedAmount ,
2078
+ Zero
2061
2079
)
2062
- await expect ( tx )
2063
- . to . emit ( tokenStaking , "AuthorizationIncreased" )
2064
- . withArgs (
2080
+ await assertApplicationStakingProviders (
2081
+ application2Mock ,
2065
2082
stakingProvider . address ,
2066
- application2Mock . address ,
2067
- authorized2 ,
2068
- authorized2 . add ( topUpAmount )
2083
+ authorized2 . add ( topUpAmount ) ,
2084
+ Zero
2069
2085
)
2086
+ } )
2087
+
2088
+ it ( "should emit AuthorizationIncreased" , async ( ) => {
2089
+ await expect ( tx )
2090
+ . to . emit ( tokenStaking , "AuthorizationIncreased" )
2091
+ . withArgs (
2092
+ stakingProvider . address ,
2093
+ application1Mock . address ,
2094
+ authorized1 ,
2095
+ expectedAmount
2096
+ )
2097
+ await expect ( tx )
2098
+ . to . emit ( tokenStaking , "AuthorizationIncreased" )
2099
+ . withArgs (
2100
+ stakingProvider . address ,
2101
+ application2Mock . address ,
2102
+ authorized2 ,
2103
+ authorized2 . add ( topUpAmount )
2104
+ )
2105
+ } )
2070
2106
} )
2071
2107
} )
2072
2108
} )
@@ -2130,7 +2166,7 @@ describe("TokenStaking", () => {
2130
2166
. toggleAutoAuthorizationIncrease ( stakingProvider . address )
2131
2167
} )
2132
2168
2133
- it ( "should enable auto increase flag" , async ( ) => {
2169
+ it ( "should disable auto increase flag" , async ( ) => {
2134
2170
expect (
2135
2171
await tokenStaking . getAutoIncreaseFlag ( stakingProvider . address )
2136
2172
) . to . equal ( false )
0 commit comments