Submitting this because I dont have the time (or resources) to debug this atm and need a self-reminder:
On Win32 walletpassphrase does not appear to relock after the designated amount of time as it should and as it does on Linux.
Can someone check this on OSX as well?

{
    CWallet wallet(m_node.chain.get(), "", m_args, CreateDummyWalletDatabase());
    CWalletTx wtx{m_coinbase_txns.back(), TxStateConfirmed{m_node.chainman->ActiveChain().Tip()->GetBlockHash(), m_node.chainman->ActiveChain().Height(), 0}};
    LOCK(wallet.cs_wallet);
    wallet.SetWalletFlag(WALLET_FLAG_DESCRIPTORS);
    wallet.SetupDescriptorScriptPubKeyMans();
    wallet.SetLastBlockProcessed(m_node.chainman->ActiveChain().Height(), m_node.chainman->ActiveChain().Tip()->GetBlockHash());
    
    
    BOOST_CHECK_EQUAL(CachedTxGetImmatureCredit(wallet, wtx), 0);
    
    
    wtx.MarkDirty();
    AddKey(wallet, coinbaseKey);
    BOOST_CHECK_EQUAL(CachedTxGetImmatureCredit(wallet, wtx), 50*COIN);
}
static int64_t AddTx(ChainstateManager& chainman, CWallet& wallet, uint32_t lockTime, int64_t mockTime, int64_t blockTime)