In 1652, Catalonia's rebellion against Spain collapsed, and in 1659, Spain ended its war with France and so there were grounds for Spanish optimism in its struggle to regain control over Portugal. However, Portugal could draw on the wealth of Brazil and the aid of first France and then England, but Spain's finances were perpetually in crisis.