Iran has made its position clear. If it is prevented from using the Straight of Hormuz, then it will prevent everyone from using the Strait.
What is not clear, however, is if Iran considers across-the-board sanctions on all Iranian exports/trade as a de facto closing of the Straight.
If this is the case, or if Iran wishes to signal that it believes that is indeed the case, then a low-cost, low-risk move such as the pair of recent attacks on a methanol and on a naphtha carrier may have been exactly the message that Iran wishes to convey.
The attacks may have also been a way for Iran, assuming it was behind the attacks, to communicate to other states in the area that it may not be in their own self interest to participate in the UAE-Saudi-US axis.
If I recall my history texts correctly, Iran has not invaded a neighboring for well over two centuries, which certainly suggests that Iran is not an aggressor state. However, this does not mean or imply that Iran, if it feels itself to be under siege, will not share the pain with its neighbors. In fact, Iran has been explicit about this — it does not have the ability or the willingness to take on the US in a conventional war, but it certainly can and will make US regional allies pay dearly in the event of any US attack on Iran. The recent Houthis (counter) attacks against the Saudis make it more than clear that Saudi Arabia’s oil infrastructure is at risk from small but well targeted attacks.
In a battle of If-You-Fuck-with-my-Trading, I-will-Fuck-with-your-Trading, Iran may have the the upper hand, and it is also probably well aware that Trump’s voter base has no interest in yet another long, bloody regional adventure. Iran can and will use its own Trump card — targeted asymmetric attacks to threaten the Straight of Hormuz — should it deem that US sanctions are but a high-tech device designed to close off Iran’s trading routes.
One should also not forget that, should push come to shove, Iran and Iraq will put aside their differences, which would open up another whole set of worries for Washington.