@@ -1984,89 +1984,126 @@ describe("TokenStaking", () => {
19841984 await tToken
19851985 . connect ( stakingProvider )
19861986 . approve ( tokenStaking . address , topUpAmount )
1987- tx = await tokenStaking
1988- . connect ( stakingProvider )
1989- . topUp ( stakingProvider . address , topUpAmount )
19901987 } )
1988+
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 )
19911997
1992- it ( "should update T staked amount" , async ( ) => {
1993- await assertStake ( stakingProvider . address , expectedAmount )
1998+ await expect (
1999+ tokenStaking
2000+ . connect ( stakingProvider )
2001+ . topUp ( stakingProvider . address , topUpAmount )
2002+ ) . to . be . revertedWith ( "Application is not approved" )
2003+ } )
19942004 } )
2005+
2006+ context ( "when one of applications is disabled" , ( ) => {
2007+ it ( "should revert" , async ( ) => {
2008+ await tokenStaking
2009+ . connect ( deployer )
2010+ . disableApplication ( application2Mock . address )
19952011
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 ) )
2012+ await expect (
2013+ tokenStaking
2014+ . connect ( stakingProvider )
2015+ . topUp ( stakingProvider . address , topUpAmount )
2016+ ) . to . be . revertedWith ( "Application is not approved" )
2017+ } )
20092018 } )
20102019
2011- it ( "should increase authorized amount" , async ( ) => {
2012- expect (
2013- await tokenStaking . getMaxAuthorization ( stakingProvider . address )
2014- ) . to . equal ( expectedAmount )
2015- } )
2020+ context ( "when all applications are approved" , ( ) => {
2021+
2022+ beforeEach ( async ( ) => {
2023+ tx = await tokenStaking
2024+ . connect ( stakingProvider )
2025+ . topUp ( stakingProvider . address , topUpAmount )
2026+ } )
20162027
2017- it ( "should emit ToppedUp event" , async ( ) => {
2018- await expect ( tx )
2019- . to . emit ( tokenStaking , "ToppedUp" )
2020- . withArgs ( stakingProvider . address , topUpAmount )
2021- } )
2028+ it ( "should update T staked amount" , async ( ) => {
2029+ await assertStake ( stakingProvider . address , expectedAmount )
2030+ } )
20222031
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- } )
2032+ it ( "should not increase available amount to authorize " , async ( ) => {
2033+ expect (
2034+ await tokenStaking . getAvailableToAuthorize (
2035+ stakingProvider . address ,
2036+ application1Mock . address
2037+ )
2038+ ) . to . equal ( 0 )
2039+ expect (
2040+ await tokenStaking . getAvailableToAuthorize (
2041+ stakingProvider . address ,
2042+ application2Mock . address
2043+ )
2044+ ) . to . equal ( amount . sub ( authorized2 ) )
2045+ } )
20372046
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- } )
2047+ it ( "should increase authorized amount" , async ( ) => {
2048+ expect (
2049+ await tokenStaking . getMaxAuthorization ( stakingProvider . address )
2050+ ) . to . equal ( expectedAmount )
2051+ } )
20522052
2053- it ( "should emit AuthorizationIncreased" , async ( ) => {
2054- await expect ( tx )
2055- . to . emit ( tokenStaking , "AuthorizationIncreased" )
2056- . withArgs (
2053+ it ( "should emit ToppedUp event" , async ( ) => {
2054+ await expect ( tx )
2055+ . to . emit ( tokenStaking , "ToppedUp" )
2056+ . withArgs ( stakingProvider . address , topUpAmount )
2057+ } )
2058+
2059+ it ( "should increase authorized amounts" , async ( ) => {
2060+ expect (
2061+ await tokenStaking . authorizedStake (
2062+ stakingProvider . address ,
2063+ application1Mock . address
2064+ )
2065+ ) . to . equal ( expectedAmount )
2066+ expect (
2067+ await tokenStaking . authorizedStake (
2068+ stakingProvider . address ,
2069+ application2Mock . address
2070+ )
2071+ ) . to . equal ( authorized2 . add ( topUpAmount ) )
2072+ } )
2073+
2074+ it ( "should inform application" , async ( ) => {
2075+ await assertApplicationStakingProviders (
2076+ application1Mock ,
20572077 stakingProvider . address ,
2058- application1Mock . address ,
2059- authorized1 ,
2060- expectedAmount
2078+ expectedAmount ,
2079+ Zero
20612080 )
2062- await expect ( tx )
2063- . to . emit ( tokenStaking , "AuthorizationIncreased" )
2064- . withArgs (
2081+ await assertApplicationStakingProviders (
2082+ application2Mock ,
20652083 stakingProvider . address ,
2066- application2Mock . address ,
2067- authorized2 ,
2068- authorized2 . add ( topUpAmount )
2084+ authorized2 . add ( topUpAmount ) ,
2085+ Zero
20692086 )
2087+ } )
2088+
2089+ it ( "should emit AuthorizationIncreased" , async ( ) => {
2090+ await expect ( tx )
2091+ . to . emit ( tokenStaking , "AuthorizationIncreased" )
2092+ . withArgs (
2093+ stakingProvider . address ,
2094+ application1Mock . address ,
2095+ authorized1 ,
2096+ expectedAmount
2097+ )
2098+ await expect ( tx )
2099+ . to . emit ( tokenStaking , "AuthorizationIncreased" )
2100+ . withArgs (
2101+ stakingProvider . address ,
2102+ application2Mock . address ,
2103+ authorized2 ,
2104+ authorized2 . add ( topUpAmount )
2105+ )
2106+ } )
20702107 } )
20712108 } )
20722109 } )
@@ -2130,7 +2167,7 @@ describe("TokenStaking", () => {
21302167 . toggleAutoAuthorizationIncrease ( stakingProvider . address )
21312168 } )
21322169
2133- it ( "should enable auto increase flag" , async ( ) => {
2170+ it ( "should disable auto increase flag" , async ( ) => {
21342171 expect (
21352172 await tokenStaking . getAutoIncreaseFlag ( stakingProvider . address )
21362173 ) . to . equal ( false )
0 commit comments