File: multisig.move
483:     fun is_proposal_expired(
484:         max_period: &Period, proposal_height: u64, proposal_timestamp: u64
485:     ): bool {
486:         let (height, timestamp) = get_block_info();
487:         let expired_height =
488:             if (option::is_some(&max_period.height)) {
489:                 let max_voting_period_height = *option::borrow(&max_period.height);
490:  >>>>           (max_voting_period_height + proposal_height) >= height
491:             } else { false };
492: 
493:         let expired_timestamp =
494:             if (option::is_some(&max_period.timestamp)) {
495:                 let max_voting_period_timestamp = *option::borrow(&max_period.timestamp);
496: >>>>            (max_voting_period_timestamp + proposal_timestamp) >= timestamp
497:             } else { false };
498: 
499:         expired_height || expired_timestamp
500:     }
#[test(
    account1 = @0x101, account2 = @0x102, account3 = @0x103
)]
#[expected_failure(abort_code = 0x30005)] // Add this line to expect the EPROPOSAL_EXPIRED error
fun test_proposal_expiration_bug(
    account1: signer,
    account2: signer,
    account3: signer
) acquires MultisigWallet {
    // create multisig wallet
    let addr1 = signer::address_of(&account1);
    let addr2 = signer::address_of(&account2);
    let addr3 = signer::address_of(&account3);

    // Create multisig with 100 block voting period
    create_multisig_account(
        &account1,
        string::utf8(b"multisig wallet"),
        vector[addr1, addr2, addr3],
        2,
        option::some(100), // max voting period of 100 blocks
        option::none()
    );
    let multisig_addr = object::create_object_address(&addr1, b"multisig wallet");

    // Set initial block height to 1000
    set_block_info(1000, 0);
    
    // Create proposal at height 1000
    create_proposal(
        &account1,
        multisig_addr,
        @minitia_std,
        string::utf8(b"multisig"),
        string::utf8(b"update_config"),
        vector[],
        vector[
            std::bcs::to_bytes(&vector[addr1, addr2]),
            std::bcs::to_bytes(&2u64),
            std::bcs::to_bytes(&option::none<u64>()),
            std::bcs::to_bytes(&option::none<u64>())
        ]
    );

    // Move to height 1101 (proposal should be expired)
    // Since 1101 > (1000 + 100)
    set_block_info(1101, 0);
    
    // This should fail with EPROPOSAL_EXPIRED
    vote_proposal(&account1, multisig_addr, 1, true);
}
INCLUDING DEPENDENCY MoveNursery
INCLUDING DEPENDENCY MoveStdlib
BUILDING MinitiaStdlib
Running Move unit tests
[ FAIL    ] 0x1::multisig::test_proposal_expiration_bug

Test Statistics:


                  Test Name                      Time             Gas Used          

 0x1::multisig::test_proposal_expiration_bug    0.047               61103           


Test failures:

Failures in 0x1::multisig:

 test_proposal_expiration_bug 
 Test did not error as expected


Test result: FAILED. Total tests: 1; passed: 0; failed: 1
INCLUDING DEPENDENCY MoveNursery
INCLUDING DEPENDENCY MoveStdlib
BUILDING MinitiaStdlib
Running Move unit tests
[ PASS    ] 0x1::multisig::test_proposal_expiration_bug

Test Statistics:


                  Test Name                      Time             Gas Used          

 0x1::multisig::test_proposal_expiration_bug    0.054               59229           


Test result: OK. Total tests: 1; passed: 1; failed: 0
fun is_proposal_expired(
    max_period: &Period, proposal_height: u64, proposal_timestamp: u64
): bool {
    let (height, timestamp) = get_block_info();
    let expired_height =
        if (option::is_some(&max_period.height)) {
            let max_voting_period_height = *option::borrow(&max_period.height);
-            (max_voting_period_height + proposal_height) >= height
+            height >= (max_voting_period_height + proposal_height)  
        } else { false };

    let expired_timestamp =
        if (option::is_some(&max_period.timestamp)) {
            let max_voting_period_timestamp = *option::borrow(&max_period.timestamp);
-            (max_voting_period_timestamp + proposal_timestamp) >= timestamp
+            timestamp >= (max_voting_period_timestamp + proposal_timestamp)
        } else { false };

    expired_height || expired_timestamp
}
